[Bug c/80745] inconsistent warning: large integer implicitly truncated to unsigned type

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 15 03:32:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80745

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The reason for the missing warning is that in the latter two cases the
initializer expression itself wraps around to zero, which isn't diagnosed or
detected, and the initialization then isn't diagnosed.

It seems that unsigned integer wrapping should be diagnosed independently of
signed integer overflow (e.g., under -Wtruncation or something like that), and
consistently for any kind of unsigned truncation or wrapping.

As a data point, Clang diagnoses the truncation with -Wconstant-conversion, but
it also fails to diagnose the same two cases as GCC.


More information about the Gcc-bugs mailing list