public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check
@ 2012-12-07 14:03 fweimer at redhat dot com
2012-12-07 14:39 ` [Bug tree-optimization/55616] " rguenth at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2012-12-07 14:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
Bug #: 55616
Summary: bogus warning about undefined overflow after overflow
check
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: fweimer@redhat.com
CC: nils@redhat.com
Created attachment 28893
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28893
overflow-check.c
Code which performs proper overflow checking results in a compiler warning (at
-O2, without -fwrapv):
overflow-check.c:9:6: warning: assuming signed overflow does not occur when
assuming that (X + c) < X is always false [-Wstrict-overflow]
if (a > b)
^
I'm surprised that the call to something from f is not optimized away with
-fwrapv. Shouldn't VRP catch this? Addressing this missed optimization
opportunity might also fix the warning.
The g function in the test case intends to make the if statement in r actually
relevant.
This is not a regression, it happens with 4.7.2 as well.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
@ 2012-12-07 14:39 ` rguenth at gcc dot gnu.org
2013-01-31 9:50 ` fweimer at redhat dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-07 14:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-12-07
Ever Confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-07 14:38:48 UTC ---
It's not VRP that warns here but we perform the simplification before reaching
VRP, from forward-propagation which just sees
long b = a + C;
if (a > b)
something ();
and uses fold to simplify a > a + C. There it assumes that overflow
does not occur.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
2012-12-07 14:39 ` [Bug tree-optimization/55616] " rguenth at gcc dot gnu.org
@ 2013-01-31 9:50 ` fweimer at redhat dot com
2013-01-31 10:09 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2013-01-31 9:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |than at redhat dot com
--- Comment #2 from Florian Weimer <fweimer at redhat dot com> 2013-01-31 09:50:26 UTC ---
Okular triggers this warning as well, in
dviRenderer::TPIC_addPath_special(const QString& cp), due to:
if (TPIC_path.size() == number_of_elements_in_path)
TPIC_path.resize(number_of_elements_in_path+100);
QVector::resize(int) is defined as:
template <typename T>
void QVector<T>::resize(int asize)
{ realloc(asize, (asize > d->alloc || (!d->capacity && asize < d->size && asize
< (d->alloc >> 1))) ?
QVectorData::grow(sizeOfTypedData(), asize, sizeof(T),
QTypeInfo<T>::isStatic)
: d->alloc); }
asize < d->size turns into d->size < d->size + 100 and triggers the warning.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
2012-12-07 14:39 ` [Bug tree-optimization/55616] " rguenth at gcc dot gnu.org
2013-01-31 9:50 ` fweimer at redhat dot com
@ 2013-01-31 10:09 ` jakub at gcc dot gnu.org
2013-01-31 10:26 ` fweimer at redhat dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-01-31 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-31 10:08:21 UTC ---
I don't see anything bogus on the warning, it is useful to inform the developer
about potentially unintended optimization removing some conditional.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (2 preceding siblings ...)
2013-01-31 10:09 ` jakub at gcc dot gnu.org
@ 2013-01-31 10:26 ` fweimer at redhat dot com
2013-01-31 10:48 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2013-01-31 10:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #4 from Florian Weimer <fweimer at redhat dot com> 2013-01-31 10:26:12 UTC ---
(In reply to comment #3)
> I don't see anything bogus on the warning, it is useful to inform the developer
> about potentially unintended optimization removing some conditional.
Neither programmer wrote (X + c) < X, this pattern does not occur in Okular nor
Qt. I'm open to labeling the warning as "very difficult to diagnose" or
"unhelpful" in these cases, and not "bogus". But I think it's a problem
because it distracts from the real problems this warning intends to catch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (3 preceding siblings ...)
2013-01-31 10:26 ` fweimer at redhat dot com
@ 2013-01-31 10:48 ` rguenth at gcc dot gnu.org
2013-01-31 10:52 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-01-31 10:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-31 10:47:55 UTC ---
(In reply to comment #4)
> (In reply to comment #3)
> > I don't see anything bogus on the warning, it is useful to inform the developer
> > about potentially unintended optimization removing some conditional.
>
> Neither programmer wrote (X + c) < X, this pattern does not occur in Okular nor
> Qt. I'm open to labeling the warning as "very difficult to diagnose" or
> "unhelpful" in these cases, and not "bogus". But I think it's a problem
> because it distracts from the real problems this warning intends to catch.
Well, but the possible overflow is present in the literal
'number_of_elements_in_path+100'. Yes, hard to track the warning down to
that possible issue, but I don't think we can improve much on that front.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (4 preceding siblings ...)
2013-01-31 10:48 ` rguenth at gcc dot gnu.org
@ 2013-01-31 10:52 ` jakub at gcc dot gnu.org
2013-01-31 11:06 ` fweimer at redhat dot com
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-01-31 10:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-31 10:52:15 UTC ---
Just write
number_of_elements_in_path+100U
or use unsigned type for
number_of_elements_in_path
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (5 preceding siblings ...)
2013-01-31 10:52 ` jakub at gcc dot gnu.org
@ 2013-01-31 11:06 ` fweimer at redhat dot com
2013-01-31 11:14 ` than at redhat dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2013-01-31 11:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #7 from Florian Weimer <fweimer at redhat dot com> 2013-01-31 11:05:48 UTC ---
(In reply to comment #6)
> Just write
> number_of_elements_in_path+100U
> or use unsigned type for
> number_of_elements_in_path
Thanks, this is helpful. It seems you need both (number_of_elements_in_path
already is of type quint16), otherwise the expression is promoted to int. I
think it might be a permanent fix (not dependent on current optimizer behavior)
because of the GCC extension ensuring that unsigned -> int conversion is always
defined. Interesting.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (6 preceding siblings ...)
2013-01-31 11:06 ` fweimer at redhat dot com
@ 2013-01-31 11:14 ` than at redhat dot com
2013-01-31 11:21 ` jakub at gcc dot gnu.org
2021-09-28 9:37 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: than at redhat dot com @ 2013-01-31 11:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #8 from Than Ngo <than at redhat dot com> 2013-01-31 11:14:25 UTC ---
number_of_elements_in_path is already defined as unsigned type, so we need both
in this case to get rid of this warning
thanks
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (7 preceding siblings ...)
2013-01-31 11:14 ` than at redhat dot com
@ 2013-01-31 11:21 ` jakub at gcc dot gnu.org
2021-09-28 9:37 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-01-31 11:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-01-31 11:20:41 UTC ---
You haven't provided preprocessed testcase, if
number_of_elements_in_path is unsigned short, then supposedly the compiler
could figure out that number_of_elements_in_path + 100 never overflows (on
targets where sizeof (short) < sizeof (int)), but supposedly the optimization
in that case might not see that one of the + operands has been zero extended
and the other is either constant, or zero extended too.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/55616] bogus warning about undefined overflow after overflow check
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
` (8 preceding siblings ...)
2013-01-31 11:21 ` jakub at gcc dot gnu.org
@ 2021-09-28 9:37 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-28 9:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55616
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 8+ does not warn any more. I Have not checked why yet.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-09-28 9:37 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-07 14:03 [Bug tree-optimization/55616] New: bogus warning about undefined overflow after overflow check fweimer at redhat dot com
2012-12-07 14:39 ` [Bug tree-optimization/55616] " rguenth at gcc dot gnu.org
2013-01-31 9:50 ` fweimer at redhat dot com
2013-01-31 10:09 ` jakub at gcc dot gnu.org
2013-01-31 10:26 ` fweimer at redhat dot com
2013-01-31 10:48 ` rguenth at gcc dot gnu.org
2013-01-31 10:52 ` jakub at gcc dot gnu.org
2013-01-31 11:06 ` fweimer at redhat dot com
2013-01-31 11:14 ` than at redhat dot com
2013-01-31 11:21 ` jakub at gcc dot gnu.org
2021-09-28 9:37 ` pinskia 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).