https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104657
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- An alternate way of avoiding the warning in cases when the code is safe is to make the pointer itself volatile, e.g., as below. The codegen impact should be negligible (an extra instruction on x86_. static volatile unsigned long * const volatile p0x8 = (void*)8; void bar(unsigned long v) { *p0x8 = v; } As I mentioned in bug 99578 comment 25, on the AVR target GCC supports attribute address which can be used to pin a declared object to a hardwired address like so: void bar(unsigned long v) { extern volatile unsigned long x0x8 __attribute__ ((address (0x8))); x0x8 = v; } This avoids the warning and emits object code that's equivalent to the original.