APAR status
Closed as program error.
Error description
Compile-time evaluation of a ternary operator is removing valid code resulting in incorrect output. The evaluation changes: rc = (((x=1), 0) ? 1 : 0); into: rc = 0; The 'x=1' assignment statement disappears. === TEST CASE === #include <stdio.h> int rc, x=-5; int main() { printf("x should equal 1\n"); rc = (((x=1), 0) ? 1 : 0); printf("rc=%d x=%d\n", rc, x); return 0; } $ xlc test.c $ ./a.out x should equal 1 rc=0 x=-5 $
Local fix
To stop the compile-time ternary operator evaluation add the benign built-in __builtin_constant_p(): rc = (((x=1), __builtin_constant_p(0), 0) ? 1 : 0);
Problem summary
PROBLEM DESCRIPTION: The compiler may fold conditional expressions (?, &&, ||) and incorrectly discard potential side-effects of evaluating the conditional expression. USERS AFFECTED: C++ conditional expressions with side-effects.
Problem conclusion
The fix disables folding of conditional constant expressions with side-effects.
Temporary fix
Comments
APAR Information
APAR number
LI81019
Reported component name
XL C/C++ LINUX
Reported component ID
5725C7310
Reported release
G11
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2019-09-30
Closed date
2019-11-28
Last modified date
2019-11-28
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++ LINUX
Fixed component ID
5725C7310
Applicable component levels
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSXVZZ","label":"XL C\/C++ for Linux"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"G11","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
28 November 2019