APAR status
Closed as program error.
Error description
When compiling with -O2, the resulting binary produces a memory fault. ===== COMPILE COMMAND: xlC -std=c++14 -O2 -g -DONE_PARAM -DTWO_PARAM xl-reproducer.cpp -o pgm.both ===== TESTCASE: $ cat xl-reproducer.cpp #include <iostream> struct PodStruct { int i; double d; }; #ifdef ONE_PARAM namespace one_param_initializer { struct B { PodStruct& some_struct; }; struct D : public B { D(PodStruct& s) : B{s} {} }; } // namespace one_param_initializer #endif // ONE_PARAM #ifdef TWO_PARAM namespace two_param_initializer { struct B { int some_int; PodStruct& some_struct; }; struct D : public B { D(int i, PodStruct& s) : B{i, s} {} }; } // namespace two_param_initializer #endif // TWO_PARAM int main() { PodStruct main_struct; main_struct.i = 42; main_struct.d = .123; #ifdef ONE_PARAM { one_param_initializer::D d(main_struct); std::cout << "one_param_initializer::D::some_struct.i -> " << d.some_struct.i << " (address " << &d.some_struct.i << ")" << std::endl; std::cout << "one_param_initializer::D::some_struct.d -> " << d.some_struct.d << " (address " << &d.some_struct.d << ")" << std::endl; } #endif #ifdef TWO_PARAM { int main_int = 5; two_param_initializer::D d(main_int, main_struct); std::cout << "two_param_initializer::D::some_struct.i -> " << d.some_struct.i << " (address " << &d.some_struct.i << ")" << std::endl; std::cout << "two_param_initializer::D::some_struct.d -> " << d.some_struct.d << " (address " << &d.some_struct.d << ")" << std::endl; } #endif return 0; } $ ====== ACTUAL OUTPUT: $ ./pgm.both Memory fault $ ===== EXPECTED OUTPUT: $ ./pgm.both one_param_initializer::D::some_struct.i -> 42 (address 0x7ffff30e99e0) one_param_initializer::D::some_struct.d -> 0.123 (address 0x7ffff30e99e8) two_param_initializer::D::some_struct.i -> 42 (address 0x10027f00) two_param_initializer::D::some_struct.d -> 0.123 (address 0x10027f08) $
Local fix
Temporarily remove -O2 from the compile line
Problem summary
USERS AFFECTED: Users of the legacy C++ compiler (ie xlC stanza) who make use of a brace-list for initialization of a reference member of a base class may be affected by this isue. PROBLEM DESCRIPTION: Initialization of a reference member of a base class through a brace-list specification in a constructor initializer list was not correct (ie, a uniform init for a reference in a base clas was incorrect).
Problem conclusion
The legacy C++ compiler was changed to generate correct code where the target of a brace-list initializer (a "uniform-init") is a reference member of a base class.
Temporary fix
Comments
APAR Information
APAR number
LI82915
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
2023-03-06
Closed date
2023-04-21
Last modified date
2023-04-21
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"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"G11","Line of Business":{"code":"LOB57","label":"Power"}}]
Document Information
Modified date:
21 April 2023