Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: "S. Couture & K. Musgrove" <muscou@xxxxxxxxxxxx>
  • Subject: Re: [power-gnu-discuss] -te500v2 and packed attribute
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: Wed, 07 May 2008 16:37:41 -0700

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@xxxxxxxxxxxxxxxx
(650) 331-3385 x713