[Bug c/68963] New: O3 vs. O2 discards part of loop and terminates early
mail+gccbugs at svenpeter dot me
gcc-bugzilla@gcc.gnu.org
Thu Dec 17 16:42:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68963
Bug ID: 68963
Summary: O3 vs. O2 discards part of loop and terminates early
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mail+gccbugs at svenpeter dot me
Target Milestone: ---
Created attachment 37065
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37065&action=edit
testcase to reproduce the bug
Enabling O3 runs only a part of the loop body and terminates before all
iterations. small testcase attached.
wrong result with O3:
% rm -f test123 && gcc-5.3.0 -std=c99 -W -Wall -Wextra -Wpedantic -O3 -o
test123 test123.c && ./test123
--> 3
1.000000 2.000000 3.000000 1337.000000 1337.000000 1337.000000 1337.000000
1337.000000 1337.000000 1337.000000
expected result with O2:
% rm -f test123 && gcc-5.3.0 -std=c99 -W -Wall -Wextra -Wpedantic -O2 -o
test123 test123.c && ./test123
--> 3
--> 4
--> 5
1.000000 2.000000 3.000000 1.000000 2.000000 3.000000 1337.000000 1337.000000
1337.000000 1337.000000
More information about the Gcc-bugs
mailing list