This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46096] Code produces two different outputs when optimized respectively with -O2 and without it.
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Oct 2010 14:27:20 +0000
- Subject: [Bug c++/46096] Code produces two different outputs when optimized respectively with -O2 and without it.
- Auto-submitted: auto-generated
- References: <bug-46096-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46096
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-10-20 14:27:18 UTC ---
The field is not volatile, so in the loop nothing forces ->number field to be
loaded from memory again.
So it is perfectly fine to optize the whole loop into:
if (alpha1->number!=4)
for (;;); /* Endless loop. */