On Fri, Jul 09, 2021 at 08:16:24AM +0200, Richard Biener via Gcc-patches 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. I agree. This will raise a lot of noise for embedded targets.
Similar constructs are used extensively in pretty much any microcontroller project to define macros to access I/O special-function addresses. A few random examples: http://svn.savannah.gnu.org/viewvc/avr-libc/trunk/avr-libc/include/avr/sfr_defs.h?view=markup#l128 https://sourceforge.net/p/mspgcc/msp430mcu/ci/master/tree/upstream/cc430f5123.h#l2141 https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/RTOS/RTX/SRC/rt_HAL_CM.h#L138 Regards, Dimitar > > Of course the above might be able to use __builtin_trap (); - it looks > like it is placed where control flow should never end, kind of a > __builtin_unreachable (), which means abort () might do as well. > > Richard. > > > Thanks > > Martin