http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54787
Bug #: 54787 Summary: Inconsistent -Wtype-limits warning for different-sized bitfields Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: h...@gcc.gnu.org Host: x86_64-unknown-linux-gnu For the attached test-case, GCC warns inconsistently: it warns when the bit-field is 8 bits, but not 7 nor 9 bits. The c++ front-end warns consistently for all three lines. Observed with trunk r191987, the 4.7 branch (r191916, post 4.7.2), the 4.6 branch (r191812, post4.6.3) as well as local imports from the 4.3-branch and the host compiler, "gcc-4.4.3-4.fc12.x86_64"). Other targets include crisv32-axis-linux-gnu and mipsisa32r2el-linux-gnu. Example output (note absence of warnings for lines 28 and 30): gcc -Wtype-limits -O2 -c range.c /n/pp_slask/hp/range.c: In function 'main': /n/pp_slask/hp/range.c:29: warning: comparison is always true due to limited range of data type There's a related need to turn off the warning per-expression, to avoid the need to turn it off per-file (by adding "-Wno-error=type-limits" to compilations using the common idiom of -Werror together with warnings that include -Wtype-limits).