strict aliasing and socket structures

Andrew Haley aph@redhat.com
Mon Feb 20 18:37:00 GMT 2017


On 20/02/17 17:50, Jonathan Wakely wrote:
> On 20 February 2017 at 17:46, Andrew Haley wrote:
>> On 20/02/17 17:42, Jonathan Wakely wrote:
>>> This is a real problem:
>>>
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71255
>>
>> Ah, thanks.  So it's been diagnosed already.
> 
> Yes, I think with a sufficiently new glibc and gcc there are no
> warnings, and strict-aliasing optimisations don't make bad things
> happen.
> 
> The problem is that POSIX says it Just Works, but the traditional
> implementations of sockaddr_* (which are part of the libc ABI) aren't
> actually correct w.r.t strict-aliasing.

Ah, right.  So they can't be fixed e.g. by making sockaddr_storage a
character type, or by making the functions take a void* ?  Oh dear.
To the back of the class!

Andrew.




More information about the Gcc-help mailing list