On Tue, Mar 28, 2006 at 12:19:41AM +0200, Joerg Schilling wrote:
>Steve McIntyre <[EMAIL PROTECTED]> wrote:
>>
>> As the link that I posted up-thread said, #pragma pack(1) does not
>> force alignment within a structure on arm, as that would clash with
>> the arm ABI. If you _must_ do things that way, you have to use
>> __attribute__((packed)). Better/more portable would be to have a
>> simple byte array rather than a packed structure.
>
>I would call this default behavior of GCC a bug.
>
>I'll try to verify this with the C99 standard, but in case GCC is able
>to create working code at all (using __attribute__((packed))), it seems like 
>the default behavior does not make sense.
>
>Note that countless C-programs depend on sizeof(struct something) returning
>useful values.

In what way are these not useful values? They may not be what you
expect, but It's a long-known feature of C that making assumptions
about structure layout and alignment _will_ bite you.

The default behaviour here is (apparently) as specified by the
designers of the hardware in this case. Alignment _really_ matters for
performance on some architectures, and this is one of them.

The quick-hack fix is to use the __attribute__((packed)) patch; the
real fix is to stop depending on structure setup like this - use a
byte array and work within that as appropriate.

-- 
Steve McIntyre, Cambridge, UK.                                [EMAIL PROTECTED]
Who needs computer imagery when you've got Brian Blessed?



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to