This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 2.95.2 has problems with packing and alignment on AIX4.3
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: gcc 2.95.2 has problems with packing and alignment on AIX4.3
- From: "Jeffrey Dickens" <jdickens at ersi dot com>
- Date: Thu, 04 Nov 1999 14:06:59 -0500
grahams <grahams at rcp dot co dot uk> wrote:
Jeff
I believe it's the placement of the packed attribute that's causing the problems.
.
.
.
Actually I already ruled that out.
If you'll notice in the first 4 lines of output, the __attribute__ ((packed)) in any position results in the struct being packed, and the total size being 5 (a long plus a char), but in the last 4 lines the same is not true.
Just to make sure I did re-write it with the attribute applied to the struct, after the closing brace.
Thanks, though. You say on your system having the packed attribute applied to the elements of the struct did not result in any of them being packed ? That's odd, and a definite departure from the behavior I observe on 2.6, 2.7 and 2.8.
The output:
lc size 8
lc_packed size 5
cl size 8
cl_packed size 5
dc size 16
dc_packed size 16
cd size 12
cd_packed size 9
The source:
#include <stdio.h>
struct _cl
{
char c;
long l;
};
struct _lc
{
long l;
char c;
};
struct _cd
{
char c;
double d;
};
struct _dc
{
double d;
char c;
};
struct _cl_packed
{
char c_packed ;
long l_packed ;
} __attribute__ ((packed));
struct _lc_packed
{
long l_packed ;
char c_packed ;
} __attribute__ ((packed));
struct _cd_packed
{
char c_packed ;
double d_packed ;
} __attribute__ ((packed)) ;
struct _dc_packed
{
double d_packed ;
char c_packed ;
} __attribute__ ((packed)) ;
struct _lc lc;
struct _lc_packed lc_packed;
struct _cl cl;
struct _cl_packed cl_packed;
struct _dc dc;
struct _dc_packed dc_packed;
struct _cd cd;
struct _cd_packed cd_packed;
int main (int argc, char* argv[])
{
printf ("lc size %d\n", sizeof(lc));
printf ("lc_packed size %d\n", sizeof(lc_packed));
printf ("cl size %d\n", sizeof(cl));
printf ("cl_packed size %d\n", sizeof(cl_packed));
printf ("dc size %d\n", sizeof(dc));
printf ("dc_packed size %d\n", sizeof(dc_packed));
printf ("cd size %d\n", sizeof(cd));
printf ("cd_packed size %d\n", sizeof(cd_packed));
exit (0);
}
Jeff Dickens
Software Tools Engineer
ERS Boxborough (978) 264-2832