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.