On Thu, Jul 8, 2021 at 11:16 PM Richard Biener <richard.guent...@gmail.com> 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. > > 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.
I agree. While this code is certainly intentional, abort will work just as well in practice. I committed the following to change it. Ian
a15210699cbc60bc9ed077549dcd5288a295f42c diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index ab1384d698b..4d0f44f2dd2 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -01cb2b5e69a2d08ef3cc1ea023c22ed9b79f5114 +adcf10890833026437a94da54934ce50c0018309 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 38bf7a6b255..3a30748d329 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -594,7 +594,7 @@ runtime_mstart(void *arg) gp->entry = nil; gp->param = nil; __builtin_call_with_static_chain(pfn(gp1), fv); - *(int*)0x21 = 0x21; + abort(); } if(mp->exiting) { @@ -662,7 +662,7 @@ setGContext(void) gp->entry = nil; gp->param = nil; __builtin_call_with_static_chain(pfn(gp1), fv); - *(int*)0x22 = 0x22; + abort(); } } diff --git a/libgo/runtime/runtime_c.c b/libgo/runtime/runtime_c.c index 18222c14465..bc920a5d406 100644 --- a/libgo/runtime/runtime_c.c +++ b/libgo/runtime/runtime_c.c @@ -116,7 +116,7 @@ runtime_signalstack(byte *p, uintptr n) if(p == nil) st.ss_flags = SS_DISABLE; if(sigaltstack(&st, nil) < 0) - *(int *)0xf1 = 0xf1; + abort(); } int32 go_open(char *, int32, int32)