Structure Alignment Bug in Sparc.

Nathan Sidwell nathan@codesourcery.com
Tue Aug 19 17:15:00 GMT 2003


Nitin Gupta wrote:
>>	A structure assignment statement of a struct
>>
>>>	containing a 8 byte member causes a ldd assembly
>>>	instruction to be generated.
>>
>>Ok...  Why do you think this is a bug?
> 
> 
> What causes compiler to assume that if a structure contains
> "long long" (64 bit) member any where (and not as the first member)
> then the start of the sturct will also be aligned a 8 byte boundary.
because it will be (if it were not so, the long long's alignment
could not be guaranteed)

> Err.. I think the assumption is that malloc will allign all allocation
yes. malloc is obligated to do that.

>>= 8 bytes to 8 byte boundary. Then what prevents compiler to
> 
> generate a ldd for the copy of a struct member at the start of a 
> large struct (>=8byte) that does not contain a 8 byte member?
if the struct alignment was not 8bytes, ldd would not be used.

> i.e. In the test programm if st1 contains 2 longs instead of a long long
> compiler would generate ld instead.
correct.

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk




More information about the Gcc mailing list