https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83510
Bug ID: 83510 Summary: Recent changes for -Warray-bounds trigger false positive Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- Created attachment 42933 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42933&action=edit testcase The attached testcase started to produce a warning with trunk somewhere between r255501 and r255678, with -O2 -Warray-bounds: test-Warray-bounds.c: In function 'g': test-Warray-bounds.c:18:13: warning: array subscript 4294967286 is above array bounds of 'unsigned int[10]' [-Warray-bounds=] return arr[number - 0xa]; ~~~^~~~~~~~~~~~~~ I believe it is a false positive. unsigned int arr[10]; struct xyz { unsigned int a0; }; extern void wfm(struct xyz *, int, unsigned int); static unsigned int f(struct xyz * ctx, unsigned int number) { switch (number) { case 0x9: return ctx->a0; case 0xA: case 0xB: case 0xC: case 0xD: case 0xE: case 0xF: case 0x10: case 0x11: case 0x12: case 0x13: return arr[number - 0xa]; } return 0; } int g(struct xyz * ctx) { int i; for (i = 0; i < 10; i++) { wfm(ctx, i, f(ctx, i)); } return 0; }