Fixes are available
XL C/C++ for AIX Fix Pack 7 (January 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 8 (March 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 11 (February 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 12 (May 2015 PTF) for 12.1
XL C/C++ for AIX Fix Pack 13 (August 2015 Update) for 12.1
XL C/C++ for AIX Fix Pack 14 (December 2015 Update) for 12.1
XL C/C++ for AIX Fix Pack 15 (April 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 16 (July 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 17 (November 2016 Update) for 12.1
XL C/C++ for AIX Fix Pack 18 (February 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 19 (August 2017 Update) for 12.1
XL C/C++ for AIX Fix Pack 20 (March 2018 Update) for 12.1
XL C/C++ for AIX Fix Pack 6 (December 2013 PTF) for 12.1
XL C/C++ for AIX Fix Pack 9 (July 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 10 (October 2014 PTF) for 12.1
XL C/C++ for AIX Fix Pack 21 (January 2019 Update) for 12.1
APAR status
Closed as program error.
Error description
The below test case shows that throwing of exceptions causes destructors to be skipped, and creates all sorts of strange behavior down the chain with xlC V11.1 and V12.1. xlC v10.1 works. ===== TESTCASE: $cat test.cpp #include <iostream> class MyClassEmptyDestructor { bool v1; public: MyClassEmptyDestructor() : v1(false) { // Bug exposed whether constructor is empty or not /// std::cout << "MyClass constructor" << std::endl; } ~MyClassEmptyDestructor() { // Note: must be empty: if following is activated, all destructors are called ///std::cout << "MyClass destructor" << std::endl; } }; class Canary { unsigned int m_canary; public: // Note: a parameter is required here (doesn't need to be used). Canary(unsigned int id) : m_canary(id) { std::cout << "Canary entering " << m_canary << std::endl; } ~Canary() { // Sing - note singing is mandatory std::cout << "Canary exiting " << m_canary << std::endl; } }; void test_and_throw(bool exp) { // None of these destructors will be called Canary canary1(1); Canary canary2(2); Canary canary3(3); Canary canary4(4); if(exp) { // Must have class with empty destructor here // Even though execution path does not reach. MyClassEmptyDestructor myclass; return; // This return is also essential for the bug to show } // These destructors will be called Canary canary5(5); Canary canary6(6); throw "Naked Exception"; /// This throw is essential for the bug to show } int main(int argc, char **argv) { try { std::cout << "Calling test_and_throw" << std::endl; test_and_throw(false); std::cout << "After test_and_throw" << std::endl; } catch (...) { std::cout << "Caught exception" << std::endl; } } xlC_r test.cpp $./a.out Calling test_and_throw Canary entering 1 Canary entering 2 Canary entering 3 Canary entering 4 Canary entering 5 Canary entering 6 Canary exiting 6 Canary exiting 5 Caught exception Expected Output: xlC_r test.cpp $./a.out Calling test_and_throw Canary entering 1 Canary entering 2 Canary entering 3 Canary entering 4 Canary entering 5 Canary entering 6 Canary exiting 6 Canary exiting 5 Canary exiting 4 Canary exiting 3 Canary exiting 2 Canary exiting 1 Caught exception
Local fix
Do not make the destructor empty.
Problem summary
PROBLEM DESCRIPTION: Destructors were not being called due to error in state tables. USERS AFFECTED: All users constructing classes within or after a throw / exception handling
Problem conclusion
The issue has been solved. Apply applicable service.
Temporary fix
Comments
APAR Information
APAR number
IV53340
Reported component name
XL C/C++ FOR AI
Reported component ID
5725C7200
Reported release
C10
Status
CLOSED PER
PE
NoPE
HIPER
NoHIPER
Special Attention
NoSpecatt
Submitted date
2013-12-13
Closed date
2013-12-13
Last modified date
2013-12-13
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
Document Information
Modified date:
03 October 2021