Fixes are available
APAR status
Closed as program error.
Error description
When compiling with the cc compiler, the resulting exe produces an incorrect output. ===== COMPILE COMMAND: cc test.c ===== TESTCASE: $cat test.c #include <stdio.h> #include <stdbool.h> #ifdef THIS_WORKS # define cBOOL(cbool) ((cbool) ? true : false) #else # define cBOOL(cbool) ((bool)!!(cbool)) #endif #define toUPPER(c) (cBOOL((c >= 'a' && c <= 'z')) ? (c - 32) : (c)) int main(int argc, char **argv) { while (*++argv) { char c = **argv; char u = toUPPER(c); printf("c=%d u=%d\n", c, u); } return 0; } $ ===== ACTUAL OUTPUT: $cc test.c $./a.out $ ./a.out v V c=118 u=86 c=86 u=54 $ ===== EXPECTED OUTPUT: $cc test.c $./a.out v V c=118 u=86 c=86 u=86 $
Local fix
It will produce the expected output if you compiled the test case as a C++ program.
Problem summary
USERS AFFECTED: Users who cast a non-constant expression to _Bool may be affected by this issue. PROBLEM DESCRIPTION: Casting a non-constant expression to _Bool returns incorrect results.
Problem conclusion
When the expression being casted to _Bool is non-contant, the compiler should not just pick 0 or 1 but propagate the non-contant value. This has been corrected.
Temporary fix
Comments
APAR Information
APAR number
LI76790
Reported component name
XL C/C++ FOR LI
Reported component ID
5724X1400
Reported release
B10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2012-05-24
Closed date
2012-05-24
Last modified date
2012-05-24
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
5724X1400
Applicable component levels
RB10 PSN IV11885
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":"B10","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
17 October 2021