[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#561691: Please declare struct sockaddr and sockaddr_storage as may_alias



Package: libc6-dev
Version: 2.10.2-2

Type punning between pointers to struct sockaddr, struct sockaddr_storage
and sockaddr_in(6) is explicitly required by the sockets interface.  For
example, RFC 3493 Section 3.8 gives the following example:

      if (bind(s, (struct sockaddr *) &sin6, sizeof(sin6)) == -1)

Unfortunately, gcc-4.4 with -fstrict-aliasing=2 complains on this kind
of code.  This may potentially break in code optimised with -O2 or greater
(it probably doesn't, though, since most of the code that triggers this
warning doesn't actually violate the C99 aliasing restrictions).

I suggest that the definitions of struct sockaddr and struct sockaddr_storage
should be equipped with

  __attribute__ ((may_alias))

                                        Juliusz



Reply to: