Issue |
138738
|
Summary |
Spurious -Wbitfield-enum-conversion warning when using signed enum in a bit-field
|
Labels |
new issue
|
Assignees |
|
Reporter |
brevzin
|
Short reproduction:
```cpp
#include <cstdint>
enum class E : int8_t {
sell = -1,
buy = +1,
other = 0
};
struct Data {
E e : 8;
int padding : 24 = 0;
};
struct Aux {
E e;
};
auto make_data(Aux const& aux) -> Data {
return Data{.e=aux.e};
}
```
The warning I get from clang (under `-Wconversion`) is:
```
<source>:19:20: warning: assigning value of signed enum type 'E' to unsigned bit-field 'e'; negative enumerators of enum 'E' will be converted to positive values [-Wbitfield-enum-conversion]
19 | return Data{.e=aux.e};
| ^
<source>:10:5: note: consider making the bit-field type signed
10 | E e : 8;
| ^
```
But the bit-field type _is_ signed. And I can't write `signed E` either.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs