Fixes are available
October 2010 PTF for XL C/C++ for AIX, V10.1
May 2012 PTF for XL C/C++ for AIX, V10.1
January 2013 PTF for XL C/C++ for AIX, V10.1
XL C/C++ for AIX Fix Pack 18 (July 2013 PTF) for 10.1
XL C/C++ for AIX Fix Pack 19 (October 2013 PTF) for 10.1
XL C/C++ for AIX Fix Pack 21 (October 2015 PTF) for 10.1
March 2010 PTF for XL C/C++ for AIX, V10.1
April 2010 PTF for XL C/C++ for AIX, V10.1
June 2010 PTF for XL C/C++ for AIX, V10.1
May 2011 PTF for XL C/C++ for AIX, V10.1
October 2011 PTF for XL C/C++ for AIX, V10.1
February 2012 PTF for XL C/C++ for AIX, V10.1
September 2012 PTF for XL C/C++ for AIX, V10.1
XL C/C++ for AIX Fix Pack 20 (October 2014 PTF) for 10.1
APAR status
Closed as program error.
Error description
The provided test case produces an incorrect output at runtime due to the incorrect evaluation of !((~max_juint) == 0) within the 'if' statement. ===== COMPILE COMMAND: xlC_r -q64 test.cpp ===== TESTCASE: $ cat test.cpp /********************************/ #include <stdio.h> typedef uint32_t juint; const juint max_juint = (juint)-1; /* 0xFFFFFFFF largest juint */ int main() { printf("max_juint: 0x%x\n", max_juint); printf("~max_juint: 0x%x\n", ~max_juint); printf(" ((~max_juint) == 0) : %d\n", ((~max_juint) == 0)); printf("!((~max_juint) == 0) : %d\n", !((~max_juint) == 0)); if (!((~max_juint) == 0)) { printf("*** error ***\n", max_juint); } else { printf("*** ok ***\n", max_juint); } return 0; } ===== ACTUAL OUTPUT: $ ./a.out max_juint: 0xffffffff ~max_juint: 0x0 ((~max_juint) == 0) : 1 !((~max_juint) == 0) : 0 *** error *** $ ===== EXPECTED OUTPUT: $ ./a.out max_juint: 0xffffffff ~max_juint: 0x0 ((~max_juint) == 0) : 1 !((~max_juint) == 0) : 0 *** ok *** $
Local fix
Assign the value to a temp variable before evaluating the expression within the 'if'. eg: . . uint32_t temp = ~max_juint; if (!(temp == 0)) { printf("*** error ***\n", max_juint); } else { printf("*** ok ***\n", max_juint); } . .
Problem summary
USER AFFECTED: Users using special const iteral type like HEX, in the logical comparison statement. PROBLEM DESCRIPTION: The compiler does not evaluate the non-integral literal type properly, causing the logic relation in the if-else statements is determined incorrectly.
Problem conclusion
xlCentry needs to choose proper routines to convert and evaluate the special const literal type.
Temporary fix
Comments
APAR Information
APAR number
IZ65456
Reported component name
XL C++ AIX
Reported component ID
5724U8100
Reported release
A10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2009-11-18
Closed date
2010-02-24
Last modified date
2010-02-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++ AIX
Fixed component ID
5724U8100
Applicable component levels
Document Information
Modified date:
24 February 2010