IBM Support

LI76568: DESTRUCTORS NOT CALLED ON STATIC LOCAL ARRAYS

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • Consider the following test case:
    
    /************* test.cpp*************************/
    #include <iostream>
    
    class A {
      public:
        A() { std::cout << "A ctor()" << std::endl; }
        ~A() { std::cout << "A dtor" << std::endl; }
    };
    
    class B {
      public:
        B() { std::cout << "B ctor()" << std::endl;  }
        B(const char *s) { std::cout << "B ctor(const char*)" <<
    std::endl;  }
        ~B() { std::cout << "B dtor" << std::endl; }
    };
    
    #ifdef FILE_STATIC
    static B z[] = { "first", "second" };
    #endif
    
    int main()
    {
        static A a;
        static B b[] = { "FIRST", "SECOND" };
    }
    /************ end of test.cpp ******************/
    
    Compile source file and run the resulting binary.  The
    destructors for B are not called:
    
    $ xlC test.cpp
    
    $a.out
    A ctor()
    B ctor(const char*)
    B ctor(const char*)
    A dtor
    
    
    As opposed to a correct output:
    
    $  a.out
    A ctor()
    B ctor(const char*)
    B ctor(const char*)
    B dtor
    B dtor
    A dtor
    
    On ther other hand the destructors for the static B in file
    scope are called properly, as in the case below:
    
    $ xlC_r test-static-const-aix.cpp -DFILE_STATIC
    $ a.out
    B ctor(const char*)
    B ctor(const char*)
    A ctor()
    B ctor(const char*)
    B ctor(const char*)
    A dtor
    B dtor
    B dtor
    

Local fix

  • N/A
    

Problem summary

  • Destructors not called on static local arrays with
    initialization lists
    

Problem conclusion

  • Problem had been resolved.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76568

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-01-09

  • Closed date

    2012-01-09

  • Last modified date

    2012-01-09

  • APAR is sysrouted FROM one or more of the following:

    IV00407

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

Applicable component levels



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI76568

Modified date: 09 January 2012


Translate this page: