c/2894

rearnsha@gcc.gnu.org rearnsha@gcc.gnu.org
Tue May 22 06:46:00 GMT 2001


The following reply was made to PR c/2894; it has been noted by GNATS.

From: rearnsha@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, jeffm@suse.com, nobody@gcc.gnu.org
Cc:  
Subject: Re: c/2894
Date: 22 May 2001 13:43:05 -0000

 Synopsis: Incorrect union padding on Linux/ARM port; other architectures correct
 
 State-Changed-From-To: open->closed
 State-Changed-By: rearnsha
 State-Changed-When: Tue May 22 06:43:05 2001
 State-Changed-Why:
     This is a bug in your code.  You incorrectly assume that the 
     size of the union in the middle of your struct will be 16, but
     the ARM padding rules say that this must be 32.  To make the
     overall size of your structure conform to your expectations 
     you need to pack the union as well, hence:
     
     struct test
     {
         __u32 v1;
         __u32 v2;
         __u64 v3;
         union {
             __u16 v4;
             __u16 v5;
         } u __attribute__((__packed__));
         __u16 v6;
         __u32 v7;
     } __attribute__ ((__packed__));
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2894&database=gcc



More information about the Gcc-prs mailing list