This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8996: Unreliable bitfields
- From: reichelt at igpm dot rwth-aachen dot de
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, hakonrk at fys dot uio dot no, nobody at gcc dot gnu dot org
- Date: 18 Dec 2002 23:17:03 -0000
- Subject: Re: c/8996: Unreliable bitfields
- Reply-to: reichelt at igpm dot rwth-aachen dot de, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, hakonrk at fys dot uio dot no, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
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