Bug #30274 "bool bit-field: wrong increment and decrement" is supposedly fixed
in 4.2.0 and 4.3.0.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30274

However, the underlying issue still reproduces in several ways with GCC 4.2.4
and 4.3.2.

#include <stdio.h>
struct S {
    bool f : 7;
};
struct S v = { 2 };
struct S w = { true };
int main() {
    printf("FAIL: %d is not 1\n", (int)v.f);
    w.f *= 3;
    printf("FAIL: %d is not 1\n", (int)w.f);
    return 0;
}


% g++ test.cc ; ./a.out
FAIL: 2 is not 1
FAIL: 3 is not 1

Also fails with gcc -std=c99.


-- 
           Summary: Arithmetic on bool bit-fields is incorrect
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: foo at mailinator dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39364

Reply via email to