Open smeenai opened 6 years ago
This still happens on post 16 trunk(ba7cc56782dbf4a26c0a043dd33c7949366e2b0d) https://godbolt.org/z/d9deaf46T
The following code
enum { A = 128, B=256 };
void f(signed char);
void g() {
f(A);
f(B);
}
only gives the following warning
<source>:5:7: warning: implicit conversion from '(unnamed enum at <source>:1:1)' to
'signed char' changes value from 256 to 0 [-Wconstant-conversion]
5 | f(B);
| ~ ^
1 warning generated.
it still does not warn about anything between 128 and 255
Extended Description
% cat enum.cpp enum { A = 128 }; void f(signed char); void g() { f(A); } % clang -target x86_64-linux -fsyntax-only -Wconstant-conversion enum.cpp
The implicit conversion from the enumeration type (which should be an unsigned 8 bit type) to the function parameter (a signed 8 bit type) causes a value change from 128 to -128, but -Wconstant-conversion doesn't catch that. Upping the enumeration value to anything above 255 shows the expected diagnostic.