This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/68963] New: O3 vs. O2 discards part of loop and terminates early
- From: "mail+gccbugs at svenpeter dot me" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 17 Dec 2015 16:42:28 +0000
- Subject: [Bug c/68963] New: O3 vs. O2 discards part of loop and terminates early
- Auto-submitted: auto-generated
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