public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12176] New: Incorrect size for unions with very large bitfields
@ 2003-09-05  4:53 austern at apple dot com
  2003-09-05 14:34 ` [Bug c++/12176] [ABI] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: austern at apple dot com @ 2003-09-05  4:53 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12176

           Summary: Incorrect size for unions with very large bitfields
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: austern at apple dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Consider the following C++ code (it has to be C++, because C imposes limits on bitfield sizes):
extern "C" int printf(const char*,...);

union abcde {
  char foo : 4096;
};

int main()
{
  abcde x;
  printf("%d\n", sizeof(x));
}

When I compile and run this program, I get the result "504".  That makes no sense.  I'm running it 
on a system with 8-bit bytes, so the size of an abcde object should be 512.  Somehow 8 bytes 
have been lost.

Note that this is a problem only with unions, not with structs.

I've seen the same behavior with every version of gcc I've tested, from 2.95 through today's 
mainline, and on both OS X and Linux.


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

end of thread, other threads:[~2003-12-30  1:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-05  4:53 [Bug c++/12176] New: Incorrect size for unions with very large bitfields austern at apple dot com
2003-09-05 14:34 ` [Bug c++/12176] [ABI] " bangerth at dealii dot org
2003-09-08 19:19 ` austern at apple dot com
2003-09-15  0:51 ` pinskia at gcc dot gnu dot org
2003-09-15  0:59 ` pinskia at gcc dot gnu dot org
2003-09-22  8:44 ` pinskia at gcc dot gnu dot org
2003-12-26 23:32 ` [Bug c++/12176] " pinskia at gcc dot gnu dot org
2003-12-30  1:45 ` mmitchel 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).