[Bug c/71255] Auto-annotate sockaddr related structs with may_alias

fw at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 24 11:43:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71255

--- Comment #5 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #4)
> Can you provide an example how do you envision such a pragma?  Should it
> only have an effect on "sockaddr{,_*}"-named structs?

I expect that we'd put something like this into <stdc-predef.h>:

#if defined (__GNUC__)
# if __GNUC__ >= 7
#  pragma GCC may_alias struct sockaddr
#  pragma GCC may_alias struct sockaddr_storage
#  pragma GCC may_alias struct sockaddr_in
#  pragma GCC may_alias struct sockaddr_in6
#  pragma GCC may_alias struct sockaddr_un
…
# endif  /* __GNUC__ >= 4 */
#endif  /* __GNUC__ */

After that, if GCC creates a declaration or forward definition of, say, struct
sockaddr_in, it will automatically carry the may_alias attribute.  (For
consistency, this should also apply to nested C++ namespaces etc.)


More information about the Gcc-bugs mailing list