> On 9 Jul 2021, at 09:16, Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > On Thu, Jul 8, 2021 at 8:02 PM Martin Sebor via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: >> >> Hi Ian, >> >> Yesterday's enhancement to -Warray-bounds has exposed a couple of >> issues in libgo where the code writes into an invalid constant >> address that the warning is designed to flag. >> >> On the assumption that those invalid addresses are deliberate, >> the attached patch suppresses these instances by using #pragma >> GCC diagnostic but I don't think I'm supposed to commit it (at >> least Git won't let me). To avoid Go bootstrap failures please >> either apply the patch or otherwise suppress the warning (e.g., >> by using a volatile pointer temporary). > > Btw, I don't think we should diagnose things like > > *(int*)0x21 = 0x21; > > when somebody literally writes that he'll be just annoyed by diagnostics.
And we have an assortment of similar cases in 32-bit ARM kernel-page helpers. At the moment building libatomic for arm-linux-gnueabihf fails with: === In function ‘select_test_and_set_8’, inlined from ‘select_test_and_set_8’ at /home/tcwg-buildslave/workspace/tcwg-dev-build/snapshots/gcc.git~master/libatomic/tas_n.c:115:1: /home/tcwg-buildslave/workspace/tcwg-dev-build/snapshots/gcc.git~master/libatomic/config/linux/arm/host-config.h:42:34: error: array subscript 0 is outside array bounds of ‘unsigned int[0]’ [-Werror=array-bounds] 42 | #define __kernel_helper_version (*(unsigned int *)0xffff0ffc) | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ === In libatomic/config/linux/arm/host-config.h we have: === /* Kernel helper for 32-bit compare-and-exchange. */ typedef int (__kernel_cmpxchg_t) (UWORD oldval, UWORD newval, UWORD *ptr); #define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0) /* Kernel helper for 64-bit compare-and-exchange. */ typedef int (__kernel_cmpxchg64_t) (const U_8 * oldval, const U_8 * newval, U_8 *ptr); #define __kernel_cmpxchg64 (*(__kernel_cmpxchg64_t *) 0xffff0f60) /* Kernel helper for memory barrier. */ 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) === -- Maxim Kuvyrkov https://www.linaro.org