This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37502] New: no warning for always-false/true conditions due to too small bitfields
- From: "j at uriah dot heep dot sax dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Sep 2008 20:01:08 -0000
- Subject: [Bug c/37502] New: no warning for always-false/true conditions due to too small bitfields
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Given the following code:
volatile struct {
unsigned char a: 1;
} bits;
unsigned char
getfoo(void)
{
while (bits.a < 3)
/* wait */;
return 42;
}
GCC does not emit a warning with -Wall -Wextra yet happily generates an
infinite loop since the while condition is always true due to the
limited size of the bitfield. I expected to get a warning similar to
those when using a too small integer type.
--
Summary: no warning for always-false/true conditions due to too
small bitfields
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: j at uriah dot heep dot sax dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37502