| Issue |
171783
|
| Summary |
[clang][request] Warn when bitfield is too small to hold all enum values
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
chrchr-github
|
~~~c++
struct S {
enum E : unsigned char { E0, E1, E2, E3 };
E e : 1; // warn here
};
S::E f(S::E e) {
S s{};
s.e = e;
//s.e = S::E3; // [clang-diagnostic-bitfield-constant-conversion]
return s.e;
}
int main() {
return f(S::E3);
}
~~~
Not sure if this is appropriate for clang-tidy or diagnostics.
GCC shows a warning.
https://godbolt.org/z/WTnPYTrz7
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs