Strict-aliasing rules (gcc 4.4)

Russ Allbery rra at stanford.edu
Thu Aug 20 22:30:43 UTC 2009


Julien ÉLIE <julien at trigofacile.com> writes:

> With gcc 4.4, there are lots of errors like:

> rc.c:151: error: dereferencing pointer 's_local' does break strict-aliasing rules
> rc.c:573: error: dereferencing pointer 'remote.59' does break strict-aliasing rules
> ...


> -->  if( s_local->sa_family == AF_INET6 )
>     {
>       struct sockaddr_in6 *s_l6 = (struct sockaddr_in6 *)s_local;
>       struct sockaddr_in6 *s_d6 = (struct sockaddr_in6 *)s_distant;


> --> memcpy(&remotetable[i].Address, &remote, SA_LEN((struct sockaddr *)&remote));


> What could we do for that?
> Why such calls are not fine?

I've just committed a fix.  It looks like GCC special-cases struct
sockaddr, so our use of struct sockaddr_storage pointers was confusing
matters.

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.



More information about the inn-workers mailing list