[power-gnu-discuss] -te500v2 and packed attribute

Mark Mitchell mark at codesourcery.com
Wed May 7 23:37:41 UTC 2008


S. Couture & K. Musgrove wrote:
> This seem to be a bug, the code generated is byte access only.

> # cat test.c
> struct a_packed{
>    int data;
> } __attribute__((packed));
> struct a_unpacked{
>    int data;
> };
> void test_packed(int in)
> {     struct a_packed * ptr;
>    ptr->data = in;
> }
> void test_unpacked(int in)
> {     struct a_unpacked * ptr;
>    ptr->data = in;
> }

The compiler cannot assume anything about alignment of a packed 
structure and therefore cannot assume that "ptr->data" as at a 
byte-aligned address.

-- 
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713



More information about the power-gnu-discuss mailing list