[Bug c++/51350] [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false

2017-03-10 Thread micwinx at web dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51350

Mic  changed:

   What|Removed |Added

 CC||micwinx at web dot de

--- Comment #2 from Mic  ---
I encountered the same issue on a similar code block with gcc-4.8.4 and it is
still there with gcc-5.3.0 and gcc-6.1.0.

I still think this is a bug; this is because even when doing "forwprop" and
"jump-threading" over the while loop you are only checking this particular
case. In my opinion gcc should only warn if you could do the if conversion from 

  if (suffix < pattern_length)

to

  if (0)

in all cases, in particular also in the case where the while loop condition
evaluates to true.

In more general I think gcc should not warn about certain things when just
looking at some snippet (which is here clearly done by just "jump threading
over the while loop) and not the full code block. (I could also imagine that
"forwprop" and "jump threading" are used for some optimization techniques,
still this should not lead to a warning.)

Why to warn about this if condition while the warning does not apply for the
general case in this code example is clearly bad behavior. In particular when
compiling with "(-Wall) -Werror" the code won't compile anymore which is pretty
bad and it's quite annoying to get around it.

Maybe you could rethink about this and fix this issue. Thank you.

[Bug c++/51350] [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) X is always false

2011-12-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51350

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|--- |4.7.0


[Bug c++/51350] [4.7 Regression] Bogus -Wstrict-overflow warning: assuming signed overflow does not occur when assuming that (X + c) X is always false

2011-12-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51350

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #1 from Richard Guenther rguenth at gcc dot gnu.org 2011-12-05 
15:17:08 UTC ---
This is a valid warning.  We transform (in forwprop)

  int suffix = pattern_length + 1;
...
  if (suffix  pattern_length)

to

  if (0)

which is true only when pattern_length + 1 does not overflow.
This happens after jump-threading over

  while (i  start)
suffix_table[--i] = --suffix;

in case i is = start, thus the regression is probably because of
jump-threading improvements for 4.7.