[Bug c/59156] New: code miscompiled with -O2 -fpeel-loops
mjt+gcc at tls dot msk.ru
Sat Nov 16 20:20:00 GMT 2013
Bug ID: 59156
Summary: code miscompiled with -O2 -fpeel-loops
Assignee: unassigned at gcc dot gnu.org
Reporter: mjt+gcc at tls dot msk.ru
Created attachment 31231
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.
More information about the Gcc-bugs