[PATCH]: Don't pack a typedef of a struct

Hans-Peter Nilsson hp@bitrange.com
Wed Jul 16 10:24:00 GMT 2003


On Wed, 16 Jul 2003, Nathan Sidwell wrote:
> this patch stops you trying to apply a packed attribute to a typedef
> of a struct - only the underlying struct can be packed.
>
> I also discovered that when you do pack a struct by placing the packed
> attribute after the closing '}', any variants of that struct will
> not have a packed flag set. There is no test case for that, but a C++ patch
> & test I'm about to provide will test that functionality.
>
> booted & tested on i686-pc-linux-gnu, ok?

>int ary1[sizeof (struct p1) == sizeof (p1_t1)];
>int ary2[sizeof (struct p2) == sizeof (p2_t1)];
>int ary3[sizeof (struct p1) == sizeof (struct p2)];

Typos.  Should attempt to have size -1 for the error cases,
because "int x[0];" compiles.  The code compiles without your
patch! (cross to mmix-knuth-mmixware, which should be
irrelevant)  Perhaps you forgot to run the test before your
patch too.

BTW those dg-warnings could just as well be dg-error:s; a fault
of the dg machinery as Joseph (and others before) has pointed
out.

brgds, H-P



More information about the Gcc-patches mailing list