c/8996: Unreliable bitfields
reichelt@igpm.rwth-aachen.de
reichelt@igpm.rwth-aachen.de
Wed Dec 18 15:17:00 GMT 2002
Synopsis: Unreliable bitfields
State-Changed-From-To: open->closed
State-Changed-By: reichelt
State-Changed-When: Wed Dec 18 15:17:02 2002
State-Changed-Why:
Not a bug.
Your program does not obey aliasing rules.
You can use the option "-fno-strict-aliasing" as a workaround
or you can correct your code:
int main(void)
{
union {
struct {
unsigned a : 8;
unsigned b : 23;
unsigned c : 1;
} x;
unsigned i;
} u;
u.i = -1;
u.x.c = 1;
u.x.b = 1;
u.x.a = 0;
printf("%08X\n", u.i);
return 0;
}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8996
More information about the Gcc-bugs
mailing list