IBM Support

IV97585: CONSTRUCTORS NOT CALLED FOR OBJECTS CREATED IN COMMA EXPRESSIONS

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • When using comma expressions to create objects, some destructor
    calls are seen without corresponding constructor calls.  The
    missing constructors may cause memory or illegal instruction
    errors.
    
    
       === TEST CASE ===
    
    #include <stdio.h>
    struct Test
    {
        Test()
         { printf("Test() %p\n", this); }
    
        Test(const Test &other)
         { printf("Test(const Test &) %p<-%p\n", this, &other); }
    
        Test &operator=(const Test &other)
          {
           printf("Test &operator=(const Test &) %p=%p\n",
                  this, &other);
           return *this;
          }
    
        ~Test()
         { printf("~Test() %p\n", this); }
    };
    
    Test f()
    {
        return Test();
    }
    
    int main()
    {
        Test s;
        s = ( Test(), f() );
    }
    
    
    
    $ xlC test.cpp
    $ ./a.out
    Test() 2ff216a0
    Test() 2ff216a1
    Test() 2ff216a2
    Test(const Test &) 2ff216a3<-2ff216a2
    Test &operator=(const Test &) 2ff216a0=2ff216a3
    ~Test() 2ff216a3
    ~Test() 2ff216a2
    ~Test() 2ff216a1
    ~Test() 2ff216a0
    $
    

Local fix

  • In failing scenarios using an intermediate temporary object, the
    issue can be worked around by avoid the tempoarary:
    
    
    Failing Scenario:
          Test s;
          s = ( Test(), f() );
    
    Passing Scenario:
          Test a = ( Test(), f() );
    

Problem summary

  • PROBLEM DESCRIPTION:
    Some constructor calls are missing when using comma
    expressions.
    
    USERS AFFECTED:
    Users of comma expressions that create temporaries with
    constructors such as:
    
    container s;
    s = ( container(), f() );
    

Problem conclusion

  • The problem has been fixed.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IV97585

  • Reported component name

    XL C/C++ FOR AI

  • Reported component ID

    5725C7200

  • Reported release

    D10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2017-06-29

  • Closed date

    2017-06-29

  • Last modified date

    2017-06-29

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

    IV90063

  • 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":"BU048","label":"IBM Software"},"Product":{"code":"SSGH3R","label":"XL C\/C++ for AIX"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"13.1","Edition":"","Line of Business":{"code":"LOB73","label":"Power TPS"}}]

Document Information

Modified date:
19 August 2024