This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/37502] New: no warning for always-false/true conditions due to too small bitfields


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]