https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102630
Bug ID: 102630 Summary: [12 Regression] Spurious -Warray-bounds with named address space Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jsm28 at gcc dot gnu.org CC: msebor at gcc dot gnu.org Target Milestone: --- Target: x86_64-*-* Created attachment 51560 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51560&action=edit preprocessed source This is the issue breaking building glibc for x86_64 with current mainline GCC (since July), as previously discussed in threads starting at https://gcc.gnu.org/pipermail/gcc/2021-July/236922.html and https://gcc.gnu.org/pipermail/gcc/2021-July/236933.html (discussion continues into August). Compile the attached file with -O2 -Wall -Werror and get the errors: loadmsgcat.c: In function '_nl_load_domain': loadmsgcat.c:770:22: error: array subscript 0 is outside array bounds of '__seg_fs struct pthread * __seg_fs[0]' [-Werror=array-bounds] As discussed in the previous discussions, the code generating this -Warray-bounds warning needs to check targetm.addr_space.zero_address_valid to determine whether zero or small constant addresses are valid in the given address space (there's already a suitable definition of that hook for x86, but the warning is failing to check it).