Aliasing violations in gnu_java_nio_VMChannel.c

Andrew Haley <[email protected]>
Newsgroups gmane.comp.java.classpath.devel
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.