Bug 594 - [llvm-gcc] llvm-gcc lays out bitfields backwards on big endian systems
: [llvm-gcc] llvm-gcc lays out bitfields backwards on big endian systems
Status: RESOLVED FIXED
Product: tools
Classification: Unclassified
Component: llvm-gcc
: 1.0
: Macintosh MacOS X
: P normal
Assigned To: Chris Lattner
:
: miscompilation
:
:
  Show dependency treegraph
 
Reported: 2005-07-14 01:56 CDT by Chris Lattner
Modified: 2010-02-22 12:51 CST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2005-07-14 01:56:09 CDT
This program is miscompiled by LLVM on powerpc.  It appears that bitfields are
being layed out backwards by the CFE.  This may be related to Bug 449.  It
probably also affects Sparc.  This testcase should be compiled with
-fno-strict-aliasing.

-Chris


struct X {
   int A : 4;
   int Z : 28;
};

void test(struct X *P, int A) {
   P->A = A;
}

int main() {
  int Y = ~0;
  test((struct X*)&Y, 0);
  printf("%x\n", Y);
}
Comment 1 Chris Lattner 2005-07-20 18:23:30 CDT
Fixed.  Patches here and here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050711/027100.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20050718/027152.html

Fixing this fixes NAMD, 176.gcc and others.

-Chris