https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94675
Bug ID: 94675 Summary: [9 regression] -Warray-bounds false positive with -O2 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chantry.xavier at gmail dot com Target Milestone: --- Created attachment 48319 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48319&action=edit test case Tested with gcc 9.1 9.2 and 9.3 on godbolt. Compiling with "-O2 -Warray-bounds" gives the following false positive : --- <source>: In function 'f': <source>:38:11: warning: array subscript 7 is outside array bounds of 'byte[1]' {aka 'unsigned char[1]'} [-Warray-bounds] 38 | ps->s += len; | ^~ <source>:46:6: note: while referencing 'c' 46 | byte c; | ^ Compiler returned: 0 --- Error also with -O3 but not with -O. Note that the error goes after removing the assert.