[Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning
sirl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 3 11:48:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66397
Bug ID: 66397
Summary: sanitize=undefined triggers extra -Warray-bounds
warning
Product: gcc
Version: 6.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 35691
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35691&action=edit
testcase, warns with gcc-6 -c -O2 -fsanitize=undefined
The attached testcase derived from a C++ iterator implementation relies on the
fact that the undefined pCurrent-1 is immediately nullified again by the
following pCurrent++ by the optimizer. But in current trunk r224064 the
following warning is issued:
test.c: In function 'test':
test.c:19:53: warning: array subscript is below array bounds [-Warray-bounds]
ths->pCurrent = (ths->pStart) ? ths->pStart - 1 : (stru *) 0;
^
Though the warning is not completely wrong, -Warray-bounds usually triggers
only when the value is really accessed, or? gcc-5.1 compiles the testcase
without warning.
More information about the Gcc-bugs
mailing list