public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27945]  New: Packed struct of variable length has wrong size
@ 2006-06-08  2:33 alpt at freaknet dot org
  2006-06-08  2:48 ` [Bug c/27945] " alpt at freaknet dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: alpt at freaknet dot org @ 2006-06-08  2:33 UTC (permalink / raw)
  To: gcc-bugs

Consider this test: http://hinezumilabs.org/alpt/test-pack.c

#define _PACKED_ __attribute__ ((__packed__))
int func(int levels) 
{
        struct foo {
                u_char          a;
                int32_t         b[levels];
                struct timeval _PACKED_ c[levels];
                u_int           d[4];
        }_PACKED_ pkt;

        struct bar {
                u_char          a;
                int32_t         b[levels];
                struct timeval  c[levels];
                u_int           d[4];
        }_PACKED_ pktII;

        printf("pkt %d, foo %d\n", sizeof(pkt), sizeof(struct foo));
        printf("pktII %d, bar %d\n", sizeof(pktII), sizeof(struct bar));
}

On a x86 with gcc-3.4.x/3.3.6 it prints:
pkt 65, foo 65
pktII 65, bar 65
(this is the right output)

while compiled for mips and runned on a BCM3302 (mips) with a gcc-3.4.4
it gives:
pkt 68, foo 68
pktII 68, bar 68

On a gentoo's 4.1.1 amd64:
pkt 104, foo 104
pktII 104, bar 104

On a x86 with the same version of gcc:
pkt 68, foo 68
pktII 68, bar 68

That's all ;)


-- 
           Summary: Packed struct of variable length has wrong size
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alpt at freaknet dot org


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


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

end of thread, other threads:[~2007-09-24 21:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-08  2:33 [Bug c/27945] New: Packed struct of variable length has wrong size alpt at freaknet dot org
2006-06-08  2:48 ` [Bug c/27945] " alpt at freaknet dot org
2006-06-08  3:10 ` pinskia at gcc dot gnu dot org
2006-06-08  4:52 ` alpt at freaknet dot org
2006-06-09  7:48 ` [Bug middle-end/27945] [4.0/4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-07-05 17:59 ` mmitchel at gcc dot gnu dot org
2006-08-08 16:05 ` janis at gcc dot gnu dot org
2006-08-25 19:31 ` kazu at gcc dot gnu dot org
2006-09-23 21:59 ` kazu at gcc dot gnu dot org
2006-11-14  1:10 ` [Bug middle-end/27945] [4.0/4.1/4.2/4.3 " jason at gcc dot gnu dot org
2007-02-03 17:34 ` gdr at gcc dot gnu dot org
2007-02-03 20:35 ` pinskia at gcc dot gnu dot org
2007-02-14  9:01 ` mmitchel at gcc dot gnu dot org
2007-09-24 21:01 ` jason 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).