https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101379
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- I have no easy way to test the patch so it might need a little tweaking. It looks like the __kernel_helper_version macro is used as an lvalue so the macro needs to expand to a call to the __kernel_helper_version() function which should then return a pointer (or perhaps a reference), e.g., like so: diff --git a/libatomic/config/linux/arm/host-config.h b/libatomic/config/linux/arm/host-config.h index 1520f237d73..777d08a2b85 100644 --- a/libatomic/config/linux/arm/host-config.h +++ b/libatomic/config/linux/arm/host-config.h @@ -39,8 +39,14 @@ typedef void (__kernel_dmb_t) (void); #define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0) /* Kernel helper page version number. */ -#define __kernel_helper_version (*(unsigned int *)0xffff0ffc) +static inline unsigned* +__kernel_helper_version () +{ + unsigned *volatile addr = (unsigned int *)0xffff0ffc; + return addr; +} +#define __kernel_helper_version (*__kernel_helper_version()) #ifndef HAVE_STREX static inline bool Another approach is to define a __kernel_helper_version variable as an extern unsigned*, initialize it in some .c file, and have the __kernel_helper_version macro expand to *__kernel_helper_version. As I mentioned to Richard and Jeff in our discussions of this class of warnings that all treat hardcoded addresses as invalid to detect the results of arithmetic on null pointers, a better approach is to detect the invalid arithmetic itself. That needs to happen early on, before the results turn into constant addresses that are indistinguishable from hardcoded addresses. When this detection is implemented (I'm hoping to get it done for GCC 12) the existing warnings can be relaxed.