[Bug c/17211] New: [sparc/i386]: Bitfields should be *unsigned* by default.
terra at gnome dot org
gcc-bugzilla@gcc.gnu.org
Fri Aug 27 14:51:00 GMT 2004
http://www.caldera.com/developers/devspecs/abi386-4.pdf on page 32 makes it
clear that "int x : 5" should have the range 0-31. Sun's C compiler has the
same idea on solaris.
The conform to the ABIs, -funsigned-bitfields therefore needs to be the default
for i386 and sparc at least.
-------------------------------------------------------------------------------
#include <stdio.h>
int main (int argc, char **argv)
{
struct Foo {
int x : 5;
} foo;
foo.x = 31;
printf ("%d\n", foo.x);
return 0;
}
Solaris:
> gcc-3.4 -std=c99 ~/foo.c
./a.out
-1
/opt/SUNWspro/bin/cc -xc99 ~/foo.c
./a.out
31
Linux/x86, gcc 3.3.1:
Same as gcc-3.4 on solaris.
--
Summary: [sparc/i386]: Bitfields should be *unsigned* by default.
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: terra at gnome dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: sparc-sun-solaris2.8, i586-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17211
More information about the Gcc-bugs
mailing list