This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/355: Compiler takes up an extra 4 bytes when using double in an union in a structure
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/355: Compiler takes up an extra 4 bytes when using double in an union in a structure
- From: gheydon at ihug dot com dot au
- Date: 28 Jun 2000 06:33:16 -0000
- Reply-To: gheydon at ihug dot com dot au
- Resent-Cc: gcc-prs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, gheydon@ihug.com.au
>Number: 355
>Category: c
>Synopsis: Compiler takes up an extra 4 bytes when using double in an union in a structure
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jun 27 23:36:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Gordon Heydon
>Release: gcc 2.95.2 from the precompiled versions.
>Organization:
>Environment:
AIX 4.3.3
>Description:
The problem is that when you compile a program where it has a union inside a structure which contains a double the structure take up an extra 4 bytes. The is a problem because this structure is being returned to my program from a library not compiled with gcc, and doesn't have this extra 4 bytes before the union. The attached program is what I used to determine what was causing the displacement. I was compileing with cc and the with gcc to see the difference.
>How-To-Repeat:
just do a gcc a.c and run.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="a.c"
Content-Disposition: inline; filename="a.c"
#include <stdio.h>
typedef struct xxx
{
char xxx[4];
union
{
double dbl;
float flt;
} uValue;
} test;
int main(int argc, char *argv)
{
printf("%d\n",sizeof(test));
}