This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/56982] [4.8 Regression] Bad optimization with setjmp()
- From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 02 Jul 2013 22:26:34 +0000
- Subject: [Bug tree-optimization/56982] [4.8 Regression] Bad optimization with setjmp()
- Auto-submitted: auto-generated
- References: <bug-56982-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56982
--- Comment #13 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 30431
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30431&action=edit
another example of wrong compilation
This is another example where the optimization can
go wrong.
The attached program produces expected results if
compiled with -O0:
x=0, a=1
x=1, a=1
a=1
But if compiled with -O3 and if the value "a" is placed
in a register the result is like this:
x=0, a=1
x=1, a=0
a=0
That is because longjmp has more semantic than just a branch:
It branches to the setjmp, and restores all callee saved registers to
the previos value.