When I compile this using gcc rev 3.4.5 (m68k-elf):

struct A { char            B;
           unsigned char & C; } __attribute__((packed));
unsigned char D;
A E = { 'F', D };

I get:

testpp.cpp:2: warning: ignoring packed attribute on unpacked non-POD
field `unsigned char&A::C'


sizeof( E ) == 6 (B, a byte of pad since m68k uses 16 bit alignment, and
C).

This construct compiled without warning under 3.3.3 and gave sizeof( E )
== 5.

Is this behavior under 3.4.5 (both the warning and the ignoring of the
packed attribute on the reference member) proper (justified, necessary,
good)?

BTW, the documentation for 3.4.5 (at
http://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/Type-Attributes.html#Type-At
tributes) shows the example:

          struct my_unpacked_struct
           {
              char c;
              int i;
           };
          
          struct my_packed_struct __attribute__ ((__packed__))
            {
               char c;
               int  i;
               struct my_unpacked_struct s;
            };

This example, however, gives the error:

testpp.cpp:8: error: expected unqualified-id before '{' token

Changing to:

          struct my_unpacked_struct
           {
              char c;
              int i;
           };

          struct my_packed_struct
            {
               char c;
               int  i;
               struct my_unpacked_struct s;
            }  __attribute__ ((__packed__));

Eliminates the error.

Reply via email to