Re: Aliasing violations in gnu_java_nio_VMChannel.c

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

 



2009/10/22 Andrew Haley <aph@xxxxxxxxxx>:
> This:
>
>
> #ifdef HAVE_GETPEERNAME
> #ifdef HAVE_INET6
>  struct sockaddr_in6 *addr6;
>  struct sockaddr_in6 sock_storage;
>  socklen_t socklen = sizeof (struct sockaddr_in6);
> #else
>  struct sockaddr_in sock_storage;
>  socklen_t socklen = sizeof (struct sockaddr_in);
> #endif /* HAVE_INET6 */
>
>  struct sockaddr *sockaddr = (struct sockaddr *) &sock_storage;
>
>
> is clearly an aliasing violation: sock_storage is of type struct sockaddr_in6,
> and *sockaddr is of type struct sockaddr.
>
> It would be easy enough to fix the code with a union, but I can't test it
> because gcj doesn't use this code.  I could simply compile with
> -fno-strict-aliasing.
>
> Thoughts?
>
> Andrew.
>
>

I posted a patch sometime ago to do exactly that (use a union), but
received no response:

http://developer.classpath.org/pipermail/classpath-patches/2009-June/006341.html

It does need more testing than I've had chance to give it so far, I
just haven't had time to do any more work on it.
-- 
Andrew :-)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net

PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8



[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux