Bug 59156 - code miscompiled with -O2 -fpeel-loops
Summary: code miscompiled with -O2 -fpeel-loops
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-16 20:20 UTC by Michael Tokarev
Modified: 2015-03-07 00:35 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
code demonstrating the issue (1.43 KB, text/x-csrc)
2013-11-16 20:20 UTC, Michael Tokarev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tokarev 2013-11-16 20:20:06 UTC
Created attachment 31231 [details]
code demonstrating the issue

Attached is a code which shows different results when compiled with -O2 (wrong) or -O1 (right).  Initially it was -O2 -funroll-loops which triggered the issue, but after reducing the code further I managed to get the same result with -O1 vs -O2 without any additional options.

Tested with debian gcc 4.7.2-5 x86-65 (wheezy), confirmed with 4.8.1-10 (debian/testing, also 64bits).  32bit code is not affected.

The code does not have any preprocessor directives.

I tried to reduce it further but it is a bit fragile - for example, removing a single call to free() makes the code generated to be correct.
Comment 1 Andrew Pinski 2013-11-16 20:32:47 UTC
-fno-strict-aliasing fixes it.
Comment 2 Marek Polacek 2015-03-07 00:35:51 UTC
Not a bug then.  4.7 is obsolete anyway at this point.