public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17211] New: [sparc/i386]: Bitfields should be *unsigned* by default.
@ 2004-08-27 14:51 terra at gnome dot org
  2004-08-27 16:04 ` [Bug c/17211] " jsm at polyomino dot org dot uk
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: terra at gnome dot org @ 2004-08-27 14:51 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-08-30 18:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-27 14:51 [Bug c/17211] New: [sparc/i386]: Bitfields should be *unsigned* by default terra at gnome dot org
2004-08-27 16:04 ` [Bug c/17211] " jsm at polyomino dot org dot uk
2004-08-27 16:08 ` [Bug target/17211] " pinskia at gcc dot gnu dot org
2004-08-27 16:27 ` jsm at polyomino dot org dot uk
2004-08-27 16:50 ` terra at gnome dot org
2004-08-27 17:03 ` jsm at polyomino dot org dot uk
2004-08-30 15:15 ` terra at gnome dot org
2004-08-30 15:58 ` jsm at polyomino dot org dot uk
2004-08-30 18:56 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).