Fixes are available
October 2009 Update for XL C/C++ for Linux, V10.1
June 2011 Update for XL C/C++ for Linux, V10.1
XL C/C++ for Linux Fix Pack 8 (January 2014 Update) for 10.1
August 2010 Update for XL C/C++ for Linux, V10.1
January 2011 Update for XL C/C++ for Linux, V10.1
January 2012 Update for XL C/C++ for Linux, V10.1
July 2012 Update for XL C/C++ for Linux, V10.1
APAR status
Closed as program error.
Error description
The following test case demonstrates a C++ specific issue with xlC that relates to "short" constant folding. ===== COMPILE COMMAND: xlC test.cpp ===== TESTCASE: ===Start of test.cpp===== #include <stdio.h> int main(int argc, char *argv[]) { //fails const short x = ((short)-5 + (short)4) < (short)4; //fails //const short x = ((short)-5 + (short)4) < (short)4; //fails //const short x = (short)(((short)-5 +(short)4) < (short)4); //fails //const short x = (-5 + (short)4) < 4; //fails //const short x = (short)4 - 5 < 4; //fails //const short x = (short)-5 + 4 < 4; //passes //const short x = (short)(-5 + 4) < 4; printf("x = %d\n",(int)x); printf("value = %d\n",((short)-5 + (short)4)); return 0; } ====End of test.cpp===== ===== ACTUAL OUTPUT: $ ./a.out x = 0 value = -1 ===== EXPECTED OUTPUT: $ ./a.out x = 1 value = -1
Local fix
Use the following type caste: const short x = (short)(-5 + 4) < 4;
Problem summary
Users of arithmetic operations on operands requiring integral promotion in the context of a constant expression maybe affected by this issue. Incorrect values from constant folding will appear in the form of a signed operand being evaluated as an unsigned type.
Problem conclusion
Code for integral promotions in evaluating the value of constant expressions compared a value in bits to a value in bytes and otherwise did not allow unsigned types to be promoted to signed types. This caused all types requiring promotion to be promoted to unsigned int. Correction is to multiply the value in bytes by the number of bits per byte and adjust the check to allow unsigned types to be promoted to signed types when appropriate.
Temporary fix
Comments
APAR Information
APAR number
LI75124
Reported component name
XL C/C++ SLES10
Reported component ID
5724U8300
Reported release
A10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2009-12-01
Closed date
2009-12-01
Last modified date
2009-12-01
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++ SLES10
Fixed component ID
5724U8300
Applicable component levels
RA10 PSN IZ44945
UP06/09/13
[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Document Information
Modified date:
14 October 2021