[LLVMbugs] [Bug 2724] New: problem with endianness of bitfields
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Aug 27 01:57:35 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2724
Summary: problem with endianness of bitfields
Product: tools
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: llvm-gcc
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jay.foad at antixlabs.com
CC: llvmbugs at cs.uiuc.edu
Consider this code:
$ cat bf.c
struct {
unsigned char a:4;
unsigned char b:4;
} foo = { 15, 0 };
If I compile it with GCC 4.2.1 built for mips-elf, in both big- and
little-endian modes, I get this:
$ objdir-4.2.1-mips/gcc/cc1 -meb -quiet -o - bf.c | grep -A1 ^foo
foo:
.byte 240
$ objdir-4.2.1-mips/gcc/cc1 -mel -quiet -o - bf.c | grep -A1 ^foo
foo:
.byte 15
So in big-endian mode the first field in the structure occupies the most
significant bits in the byte; in little-endian mode it occupies the least
significant bits.
However, using llvm-gcc (built from svn at revision 55368), I get this:
$ ~/llvm/objdir-gcc-svn-mips/gcc/cc1 -meb -quiet -o - bf.c | grep -A1 ^foo
foo:
.byte 15 # 0xF
$ ~/llvm/objdir-gcc-svn-mips/gcc/cc1 -mel -quiet -o - bf.c | grep -A1 ^foo
foo:
.byte 15 # 0xF
This means that big-endian MIPS code built with llvm-gcc won't interwork with
code built with GCC.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list