http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56982
Bug #: 56982
Summary: Bad optimization with setjmp()
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Target: x86_64-pc-linux-gnu
Created attachment 29883
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29883
Bug program
Compile the example program with gcc -Og jmp.c -o jmp
Run the program ./jmp and the output is
Returning 1
x = 0, n = 1
Returning 0
x = 42, n = 1
Aborted
The function g() is returning 0 the second time (after longjmp()) but the
return value, assigned to n, equals 1. With other optimization levels or with
earlier versions of gcc or with -Og -fno-tree-dominator-opts, the output is
what I expect:
Returning 1
x = 0, n = 1
Returning 0
x = 42, n = 0
This is with gcc version 4.8.0, GNU libc version 2.15.