This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/559: Alignment problem - difference to gcc 2.7.2
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/559: Alignment problem - difference to gcc 2.7.2
- From: Burkhard dot Schultheis at tde-online dot de
- Date: 20 Sep 2000 15:08:28 -0000
- Reply-To: Burkhard dot Schultheis at tde-online dot de
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, Burkhard.Schultheis@tde-online.de
>Number: 559
>Category: c
>Synopsis: Alignment problem - difference to gcc 2.7.2
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: support
>Submitter-Id: net
>Arrival-Date: Wed Sep 20 08:16:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Burkhard Schultheis
>Release: 2.95.2
>Organization:
>Environment:
AIX 4.3.3
>Description:
If you have a struct like
struct
{
int a;
int b;
union
{
double c;
}
...
then element c has an offset of 8 byte. With version 2.7.2 on AIX 4.2.1 it was only 4 bytes. If you omit the union putting the double directly in the structure, there is an offset of 4, too.
We have a 3rd party library. And now the structure layout in the library is different from the layout in our module we link to this library. -fpack_struct does not help. What to do?
>How-To-Repeat:
#include <stdio.h>
typedef struct
{
char a;
char b;
union
{
double d;
} u;
} struktur;
int main (void)
{
struktur teststruct;
printf ("offset b: %d, offset d: %d\n",
(int) &teststruct.b - (int) &teststruct,
(int) &teststruct.u.d - (int) &teststruct);
return (0);
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: