struct sockaddr_storage

2023-01-19 Thread Alejandro Colomar via Gcc

Hi!

I just received a report about struct sockaddr_storage in the man pages.  It 
reminded me of some concern I've always had about it: it doesn't seem to be a 
usable type.


It has some alignment promises that make it "just work" most of the time, but 
it's still a UB mine, according to ISO C.


According to strict aliasing rules, if you declare a variable of type 'struct 
sockaddr_storage', that's what you get, and trying to access it later as some 
other sockaddr_8 is simply not legal.  The compiler may assume those accesses 
can't happen, and optimize as it pleases.


That means that one needs to declare a union with all possible sockaddr_* types 
that are of interest, so that access as any of them is later allowed by the 
compiler (of course, the user still needs to access the correct one, but that's 
of course).


In that union, one could add a member that is of type sockaddr_storage for 
getting a more consistent structure size (for example, if some members are 
conditional on preprocessor stuff), but I don't see much value in that. 
Especially, given this comment that Igor Sysoev wrote in NGINX Unit's source code:


 * struct sockaddr_storage is:
 *128 bytes on Linux, FreeBSD, MacOSX, NetBSD;
 *256 bytes on Solaris, OpenBSD, and HP-UX;
 *   1288 bytes on AIX.
 *
 * struct sockaddr_storage is too large on some platforms
 * or less than real maximum struct sockaddr_un length.

Which makes it even more useless as a type.


Should we warn about uses of this type?  Should we recommend against using it in 
the manual page, since there's no legitimate uses of it?


Cheers,

Alex

--



OpenPGP_signature
Description: OpenPGP digital signature


gcc-10-20230119 is now available

2023-01-19 Thread GCC Administrator via Gcc
Snapshot gcc-10-20230119 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/10-20230119/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 10 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-10 revision 18bc39a4c83f8d59175061a58637de9f4b2a54d4

You'll find:

 gcc-10-20230119.tar.xz   Complete GCC

  SHA256=e15ab0ff76f397b4b3cc0a5859ded4320dba617228e47d954f90ab6f25c55c4f
  SHA1=42984a118547dc4751ec6e3962e80b4fffe66319

Diffs from 10-20230112 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-10
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.