From 26e7005728f0eea2972474e6be2905c467661237 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sat, 18 May 2024 09:33:19 +0200 Subject: socket: Use may_alias on sockaddr structs (bug 19622) This supports common coding patterns. The GCC C front end before version 7 rejects the may_alias attribute on a struct definition if it was not present in a previous forward declaration, so this attribute can only be conditionally applied. This implements the spirit of the change in Austin Group issue 1641. Suggested-by: Marek Polacek Suggested-by: Jakub Jelinek Reviewed-by: Sam James Reviewed-by: Carlos O'Donell (cherry picked from commit 8d7b6b4cb27d4dec1dd5f7960298c1699275f962) --- bits/socket.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bits/socket.h') diff --git a/bits/socket.h b/bits/socket.h index 13de124bac..772074d52a 100644 --- a/bits/socket.h +++ b/bits/socket.h @@ -149,7 +149,7 @@ enum __socket_type #include /* Structure describing a generic socket address. */ -struct sockaddr +struct __attribute_struct_may_alias__ sockaddr { __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ char sa_data[14]; /* Address data. */ @@ -166,7 +166,7 @@ struct sockaddr #define _SS_PADSIZE \ (_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype)) -struct sockaddr_storage +struct __attribute_struct_may_alias__ sockaddr_storage { __SOCKADDR_COMMON (ss_); /* Address family, etc. */ char __ss_padding[_SS_PADSIZE]; -- cgit 1.4.1