APAR status
Closed as program error.
Error description
When using the AIX math.h header file macro value INFINITY to define a variable, error messages are output at compile-time: C: "test.c", line 8.15: 1506-221 (S) Initializer must be a valid constant expression. C++: "test.cpp", line 9.28: 1540-0132 (S) The expression must be a constant expression. "test.cpp", line 9.30: 1540-0063 (S) The text "&" is unexpected. The variable being defined in C is a global/static value, and the variable being defined in C++ is a constexpr value. In both contexts, the INFINITY value needs to be a compile-time constant. The definition used by the AIX math.h header file for INFINITY is not considered compile-time constant because it generates the INFINITY floating point value using a memory reference/dereference.
Local fix
Problem summary
PROBLEM DESCRIPTION: The macros and definitions in <math.h> for HUGE_VALF, INFINITY and NAN have constructs that are not compile-time expressions, resulting in errors if they are used in situations where compile-time constants are required. USERS AFFECTED: Users of the Legacy xlc/xlC compilers who have global or static local variables (C, and if constant initialization is needed by the program, C++ as well) or constexpr expressions (C++ with -qlanglvl=extended0X) that refer to HUGE_VALF, INFINITY or NAN.
Problem conclusion
New macros are provided for HUGE_VALF, INFINITY and NAN that can be used in situations where compile time constants are required. Note that the new definitions are guarded by the macro: __FP_OVERFLOW_BASED_INF_NAN_HUGEVALF , which must be defined to get the new definitions. The default behaviour (i.e. when this macro is not defined) remains unaltered. It is important to note that the new definitions may cause problems by setting floating point error flags. Also, unexpected results may occur in floating point rounding modes that round down, notably -ym and -yz. Should such a rounding mode be active at compile time with the macro guard defined when <math.h> is processed, the compiler will flag an error on code in <math.h>. The error will indicate a conflict between declarations of a variable with a name that describes the situation, namely __cannot_combine_math_header_config_with_current_rounding_mode__ .
Temporary fix
Comments
APAR Information
APAR number
IJ41522
Reported component name
XL C/C++ FOR AI
Reported component ID
5725C7200
Reported release
G10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt / Xsystem
Submitted date
2022-08-11
Closed date
2022-11-02
Last modified date
2022-11-02
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 AI
Fixed component ID
5725C7200
Applicable component levels
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"G10","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
02 November 2022