public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning
@ 2015-06-03 11:48 sirl at gcc dot gnu.org
2015-06-03 11:56 ` [Bug c/66397] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: sirl at gcc dot gnu.org @ 2015-06-03 11:48 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/66397] sanitize=undefined triggers extra -Warray-bounds warning
2015-06-03 11:48 [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning sirl at gcc dot gnu.org
@ 2015-06-03 11:56 ` pinskia at gcc dot gnu.org
2015-06-03 12:02 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-06-03 11:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66397
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Comment on attachment 35691
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35691
testcase, warns with gcc-6 -c -O2 -fsanitize=undefined
Except it is undefined behavior to have one element before the start of an
array. And that is why it is warning. Does not matter if there is a ++ later
on.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/66397] sanitize=undefined triggers extra -Warray-bounds warning
2015-06-03 11:48 [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning sirl at gcc dot gnu.org
2015-06-03 11:56 ` [Bug c/66397] " pinskia at gcc dot gnu.org
@ 2015-06-03 12:02 ` mpolacek at gcc dot gnu.org
2015-06-03 12:12 ` sirl at gcc dot gnu.org
2015-06-22 17:56 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-06-03 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66397
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yeah, I think this isn't a bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/66397] sanitize=undefined triggers extra -Warray-bounds warning
2015-06-03 11:48 [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning sirl at gcc dot gnu.org
2015-06-03 11:56 ` [Bug c/66397] " pinskia at gcc dot gnu.org
2015-06-03 12:02 ` mpolacek at gcc dot gnu.org
@ 2015-06-03 12:12 ` sirl at gcc dot gnu.org
2015-06-22 17:56 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: sirl at gcc dot gnu.org @ 2015-06-03 12:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66397
--- Comment #3 from Franz Sirl <sirl at gcc dot gnu.org> ---
Yeah, I feared so :-(. This is a bit unfortunate though, as for our code base
we compile with -Werror=array-bounds, now when I add -fsanitize=undefined I
need to downgrade the error to a warning again. Another special casing in the
build system... From this POV I would prefer to get only the
-fsanitize=undefined runtime error.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/66397] sanitize=undefined triggers extra -Warray-bounds warning
2015-06-03 11:48 [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning sirl at gcc dot gnu.org
` (2 preceding siblings ...)
2015-06-03 12:12 ` sirl at gcc dot gnu.org
@ 2015-06-22 17:56 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-06-22 17:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66397
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Closing.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-06-22 17:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 11:48 [Bug c/66397] New: sanitize=undefined triggers extra -Warray-bounds warning sirl at gcc dot gnu.org
2015-06-03 11:56 ` [Bug c/66397] " pinskia at gcc dot gnu.org
2015-06-03 12:02 ` mpolacek at gcc dot gnu.org
2015-06-03 12:12 ` sirl at gcc dot gnu.org
2015-06-22 17:56 ` mpolacek at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).