#include <stdio.h>
struct X
{
  unsigned a:4;
};

int main()
{
  struct X x = { 63u };
  printf("%u\n", x.a);
  return 0;
}
// end.

result:
g++    bug.cpp; ./a 
15

g++ -O bug.cpp; ./a
63
wrong result!!


-- 
           Summary: bitfield wrong optimize
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: s__nakayama at infoseek dot jp


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

Reply via email to