Host endian independence
Florian Weimer
fweimer@redhat.com
Mon Sep 2 07:14:00 GMT 2019
* Joseph Myers:
> On Fri, 30 Aug 2019, Florian Weimer wrote:
>
>> The problem with the existing interfaces is that that they make it hard
>> to take alignment issues into account. See bug 20243. When used for
>> parsing packet buffers, they also tend to introduce aliasing violations.
>
> That seems like a matter of declaring your structure appropriately (with
> the right alignment if e.g. it's being allocated on the stack, or with the
> packed attribute if it might genuinely be at arbitrary alignments; with
> the may_alias attribute if it's necessary for it to alias something with a
> different effective type).
To some degree, yes, but I don't think the GCC internal type system
supports member alignment (and storage order, for the pragma), so you
need to be extremely careful when building abstractions around that. It
doesn't help that all the common targets (from my perspective) do not
have alignment traps, so bugs are difficult to spot.
Thanks,
Florian
More information about the Libc-alpha
mailing list