RFH: aliasing problems
    Ralf Corsepius 
    ralf.corsepius at rtems.org
       
    Sat Dec  9 04:40:56 UTC 2006
    
    
  
On Fri, 2006-12-08 at 11:28 -0800, Till Straumann wrote:
> Welcome to the world, ralf :-)
> 
> This way of casting struct sockaddr * and struct sockaddr_xxx *
> (xxx for the address family) is done by every application using sockets
> (and they'll all get the type-punned pointer warning).
Neither Linux nor Solaris-2.7 exhibit this behavior with their sockaddr*
types and gcc-4.1.x. FreeBSD and RTEMS do.
Linux, Solaris and Cygwin have
struct sockaddr {
  sa_family_t sa_family;
  char sa_data[14];
};
struct sockaddr_xx {
  sa_family_t sa_family;
  ....
};
FreeBSD and RTEMS have:
struct sockaddr {
  unsigned char	sa_len;
  sa_family_t sa_family;
  char sa_data[14];
};
struct sockaddr_xx {
  unsigned char sa_len;
  sa_family_t sa_family;
  ...
};
So, how does this match with strict-aliasing rules?
Ralf
    
    
More information about the users
mailing list