Skip to content

Scoped enumerations with -Wbitfield-constant-conversion are not handled the same as fixed underlying type #138449

@LevoDeLellis

Description

@LevoDeLellis

With the commented out enum clang/gcc give the same results which is the one I want
With the code below (using enum class) gcc gives me the expected results but clang gives me -2

#include <cstdio>

//enum E { A, B, C, D }; // <-- this gets C
enum class E { A, B, C, D }; // <-- this gets -2
struct S { E v : 2; long long i : 30; };

int main() {
	S s{E::C, -1};
	switch (s.v) {
		case E::C: printf("Got C\n"); return 0;
		default: printf("Got %d\n", s.v); return 0;
	}
}

clang version 19.1.7
Target: x86_64-pc-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partydiverges-from:gccDoes the clang frontend diverge from gcc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions