https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57170
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |RESOLVED
CC| |egallager at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Use -Wsign-conversion to get a warning:
$ /usr/local/bin/gcc -c -Wall -Wextra -Wconversion -Wnarrowing -pedantic
-Wswitch -Wsign-promo -Wtype-limits -Wsign-conversion -std=c++98 57170.cc
57170.cc: In function ‘int main()’:
57170.cc:4:3: warning: unsigned conversion from ‘int’ to ‘unsigned int’ changes
value from ‘-1’ to ‘4294967295’ [-Wsign-conversion]
case -1:
^~~~
$
-Wsign-conversion has to be specified explicitly in c++, but in plain c, it's
implied by -Wconversion:
$ /usr/local/bin/gcc -c -x c -Wall -Wextra -Wconversion -pedantic -Wswitch
-Wtype-limits 57170.cc
57170.cc: In function ‘main’:
57170.cc:4:3: warning: unsigned conversion from ‘int’ to ‘unsigned int’ changes
value from ‘-1’ to ‘4294967295’ [-Wsign-conversion]
case -1:
^~~~
$