[Bug c++/95148] -Wtype-limits always-false warning triggered despite comparison being avoided
vincent-gcc at vinc17 dot net
gcc-bugzilla@gcc.gnu.org
Wed Oct 26 08:47:46 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95148
Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vincent-gcc at vinc17 dot net
--- Comment #2 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Simpler code, also for C:
int f (void)
{
unsigned int x = 5;
return 0 && x < 0 ? 1 : 0;
}
Alternatively:
int f (void)
{
unsigned int x = 5;
if (0)
return x < 0 ? 1 : 0;
return 0;
}
With -Wtype-limits, GCC 12.2.0 warns on both.
More information about the Gcc-bugs
mailing list