A fix is available
APAR status
Closed as program error.
Error description
When compiling with optimization, the return value from a call/jump to setjmp is not saved. This may result in incorrect program behaviour, or invalid looping between setjmp/longjmp. === TEST CASE === #include <stdio.h> #include <setjmp.h> #include <stdlib.h> int main(int argc, char *argv[]) { int ret; jmp_buf jmpbuf; ret = _setjmp(jmpbuf); //__fence(); // WORKAROUND if (ret == 0) { int raise = argc > 1 ? atoi(argv[1]) : 0; printf("Expected Code Path ... 1\n"); if (raise) _longjmp(jmpbuf, 100); } if (ret == 100) printf("Expected Code Path ... 2\n"); return 0; } $ xlc -q64 tc2.c $ ./a.out 11 Expected Code Path ... 1 Expected Code Path ... 2 $ $ xlc -q64 tc2.c -O2 $ ./a.out 11 Expected Code Path ... 1 $
Local fix
Compile without optimization, or insert an optimization __fence() call after the setjmp() call.
Problem summary
PROBLEM DESCRIPTION: The result from __setjmp is not saved and if the result variable is accessed later it may not produce the correct result. USERS AFFECTED: Only a problem if the return value from __setjmp is used.
Problem conclusion
The fix will make volatile declaration unnecessary as the compiler will know to treat the result of __setjmp differently.
Temporary fix
Comments
APAR Information
APAR number
LI78458
Reported component name
XL C/C++ FOR LI
Reported component ID
5725C7300
Reported release
D10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2015-02-25
Closed date
2015-02-25
Last modified date
2015-02-25
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fix information
Fixed component name
XL C/C++ FOR LI
Fixed component ID
5725C7300
Applicable component levels
RD10 PSN IV62226
UP06/09/13
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"13.1","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
17 October 2021