https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108306
Bug ID: 108306
Summary: false-positive -Warray-bounds warning emitted with
-fsanitize=shift
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: kees at outflux dot net
Target Milestone: ---
Created attachment 54198
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54198&action=edit
reduced PoC
This seems similar to bug #105679, but is still present in GCC 13 (and 12).
Something about -fsanitize=shift really confuses -Warray-bounds:
poc2.c: In function 'e':
poc2.c:12:8: warning: array subscript 32 is above array bounds of 'int[4]'
[-Warray-bounds=]
12 | c.d[f]++;
| ~~~^~~
poc2.c:4:7: note: while referencing 'd'
4 | int d[MAX];
| ^
poc2.c:12:8: warning: array subscript 32 is above array bounds of 'int[4]'
[-Warray-bounds=]
12 | c.d[f]++;
| ~~~^~~
poc2.c:4:7: note: while referencing 'd'
4 | int d[MAX];
| ^