public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jeffm@suse.com
To: gcc-gnats@gcc.gnu.org
Subject: c/2894: Incorrect union padding on Linux/ARM port; other architectures correct
Date: Mon, 21 May 2001 22:26:00 -0000	[thread overview]
Message-ID: <20010522052115.2476.qmail@sourceware.cygnus.com> (raw)

>Number:         2894
>Category:       c
>Synopsis:       Incorrect union padding on Linux/ARM port; other architectures correct
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon May 21 22:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Jeff Mahoney <jeffm@suse.com>
>Release:        gcc version 2.95.2; gcc version 2.95.4 20010319 (Debian prerelease); gcc version 3.1 20010512 (experimental) (from netwinder.org)
>Organization:
>Environment:
Debian Linux [stable]
Intel StrongARM-1110 rev 6 (v4l)
Compaq iPAQ
>Description:
Incorrect union padding is produced on the Linux/ARM port. It seems that the alignment padding corrections are applied too early, so the size of the structure is incorrectly calculated, thus a structure is sized too large. This problem is surfacing in running ReiserFS on Linux/ARM, where incorrect sizes/offsets for on-disk structures are being generated. Linux/PPC, Linux/Intel, Solaris/Sparc, and Tru64/Alpha ports produce correct sizes/offsets. A simplified test case is attached.

See PR #2547 for somewhat related info.
>How-To-Repeat:
#include <stdio.h>
#include <linux/types.h>
struct test2
{
    __u32 v1;
    __u32 v2;
    __u64 v3;
    __u16 v4_5;
    __u16 v6;
    __u32 v7;
} __attribute__ ((__packed__));
 
struct test
{
    __u32 v1;
    __u32 v2;
    __u64 v3;
    union {
        __u16 v4;
        __u16 v5;
    } u;
    __u16 v6;
    __u32 v7;
} __attribute__ ((__packed__));

int
main( void )
{
    printf( "sizeof( struct test ) = %d\n", sizeof( struct test ) );
    printf( "sizeof( struct test2 ) = %d\n", sizeof( struct test2 ) );
}
Output for ARM:
sizeof( struct test ) = 26
sizeof( struct test2 ) = 24

(without __attribute__ ((__packed__)), sizeof( struct test ) = 28)

Output for other tested arches (see desc. for list):
sizeof( struct test ) = 24
sizeof( struct test2 ) = 24
(results are the same without __attribute__ ((__packed__)) )
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-05-21 22:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-21 22:26 jeffm [this message]
2001-05-21 22:56 Neil Booth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010522052115.2476.qmail@sourceware.cygnus.com \
    --to=jeffm@suse.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).