This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/20111] struct sockaddr_storage cannot be aggregate-copied


https://sourceware.org/bugzilla/show_bug.cgi?id=20111

--- Comment #4 from rguenther at suse dot de ---
On Wed, 18 May 2016, fweimer at redhat dot com wrote:

> https://sourceware.org/bugzilla/show_bug.cgi?id=20111
> 
> --- Comment #3 from Florian Weimer <fweimer at redhat dot com> ---
> (In reply to rguenther from comment #2)
> > Making the struct incomplete would do the trick and force heap
> > allocation (or allocation via alloca).  But I guess that would break
> > too much code out in the wild.
> 
> This is totally impractical, the type is part of the ABI.
> 
> In general. there is an expectation that you can use struct sockaddr_storage as
> some sort of generic socket address.  POSIX also requires that it has a
> positive size and sufficient alignment (so that you can store a copy of struct
> sockaddr_un in it).  This does not necessarily mean that objects of struct
> sockaddr_storage can be copied with an aggregate copy.
> 
> POSIX also requires that the ss_family member of struct sockaddr_storage and
> the sun_family member of struct sockaddr_un can alias, and there is currently
> no way to tell GCC that (there is in standard C, using a declaration of a union
> that has both structs as members).

The way to tell GCC this is to  mark all members of that "implicit" union with
the may_alias attribute.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]