https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90886
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |tree-optimization
--- Comment #12 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
As explained in comment #11, this is a tree optimizaton issue:
(In reply to Georg-Johann Lay from comment #11)
> [...]
> Reason appears to be that the C++ front-end expand the loop variable as
> signed char, and later passes think that there is some signed overflow und
> Undefined Behaviour.
>
> With -fwrapv, correct code is generated.
>
> Also, the C front end also uses signed char, but for some reason the C
> version works.
>
> A work-around is to use -fwrapv so that signed overflow wraps around.
>
> This is not a target issue, it's some tree optimization where GCC falls in
> its own pit as it tries to exploit signed overflow.
>
> I could not reproduce this with later version of the compiler. The next
> version I tried was v8.5 (I don't have other versions handy).
>
> I leave this bug open for now. Maybe the tree folks can pin down which PR
> this actually is, and when it was fixed.