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]

Re: c/8996: Unreliable bitfields


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


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