[Bug c/37502] no warning for always-false/true conditions due to too small bitfields
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Sep 28 08:38:55 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37502
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2008-09-13 12:37:20 |2021-9-28
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So this is interesting.
Since GCC 11, the C front-end warns if the struct is volatile:
<source>: In function 'getfoo':
<source>:9:23: warning: comparison is always true due to limited range of data
type [-Wtype-limits]
9 | while (bits.a < 3)
| ^
But not if it is not volatile.
Also the C++ front-end does not warn in either case.
More information about the Gcc-bugs
mailing list