This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/71177] Spurious -Waggressive-loop-optimizations warning


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71177

Tavian Barnes <tavianator at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #38516|0                           |1
        is obsolete|                            |

--- Comment #2 from Tavian Barnes <tavianator at gmail dot com> ---
Created attachment 38520
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38520&action=edit
Further reduced testcase

> Please don't set regression markers if you don't know what you are doing (but
> feel free to suggest that something should have regression markers).
>
> Happens also in 5.3.0, 4.9.3 and 7.0, so not a regression.

Oops, sorry!  This only showed up in my actual build on upgrading to GCC 6, but
I didn't check the reduced version against older GCCs.

> If you could reduce the testcase further and point out at a missing
> optimization, the chances of getting this fixed would increase. Otherwise,
> someone needs to look at the dump files and figure out why the ranges are not
> affected by the check and whether they should.

I've attached a further reduced testcase.

> The 'else' block is not unreachable, but loop optimizations look at the possible
> ranges within the loop and those may not be taking into account any range
> information derived from the caller.

The else block is unreachable *from within normalize()*.  And since the warning
only shows up due to constant propagation from normalize(), it would be nice to
avoid it.

Specifically, normalize() calls resize(length - 2) which calls (in the
unreached else block) append(n - length).  (n - length) gets constant-folded to
(size_t)-2 which then overflows a ptrdiff_t later.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]