IBM Support

LI81681: ISSUE WITH XL UNDERSTANDING CLASS MEMBER VARIABLE OFFSETS W.R.T.POLYMORPHISM AND TEMPLATING

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • COMPILER PRODUCES INCORRECT RESULTS FOR CLASS MEMBER VARIABLE
    OFFSETS W.R.T. POLYMORPHISM AND TEMPLATING
    ----------------------------------------------------------------
    
    xlC -std=c++11 testcode.C
    $ ./a.out
    
    
    Actual results:
    
    C:  &B::data2=0x7fffc9d1f910, &A2::data2=0x7fffc9d1f908,
    &B::getData2()=0x7fffc9d1f908, &A2::getData2()=0x7fffc9d1f908
    B:  &data2=0x7fffc9d1f908, &getData2()=0x7fffc9d1f908
    
    
    The expected results:
    
    C:  &B::data2=0x7fffcaf71478, &A2::data2=0x7fffcaf71478,
    &B::getData2()=0x7fffcaf71478, &A2::getData2()=0x7fffcaf71478
    B:  &data2=0x7fffcaf71478, &getData2()=0x7fffcaf71478
    
    ================================================================
    
    Test Case:
    
    #include<stdio.h>
    #include<vector>
    
    template<typename TV>
    struct myvec {
                    protected:
                    std::vector<TV> vec_data;
    };
    
    template<typename TA>
    struct A1 {
                    virtual ~A1() = default;
    };
    
    struct A2 {
                    virtual ~A2() = default;
    protected:
                    myvec<int> data1;
                    myvec<int> data2;
    
                    myvec<int> &getData1(){
                                    return data1;
                    }
                    myvec<int> &getData2(){
                                    return data2;
                    }
    };
    
    template<typename T>
    struct B : public A1<T>, public A2
    {
                    virtual ~B() = default;
    
                    void testB(){
                                    printf("B:  &data2=%p,
    &getData2()=%p\n", &(A2::data2), &getData2());
                    }
    };
    
    template<typename T2>
    struct C : public B<T2>
    {
                    using Parent = B<T2>;
                    virtual ~C() = default;
    
                    void testC(){
                                    printf("C:  &B::data2=%p,
    &A2::data2=%p, &B::getData2()=%p, &A2::getData2()=%p\n",
    &(Parent::data2), &(A2::data2), &(Parent::getData2()),
    &(A2::getData2()));
                    }
    };
    
    int main(void){
    
                    C<double> c;
    
                    c.testC();
                    c.testB();
    
                    return 0;
    }
    

Local fix

  • N/A
    

Problem summary

  • USERS AFFECTED:
    Users who have test cases similar to the one mentioned in the
    APAR are affected by this issue.
    
    PROBLEM DESCRIPTION:
    The root cause is that the compiler was incorrectly handling
    qualified base class members,
    where the qualified name is more derived than the subobject in
    which the member resides.
    

Problem conclusion

  • The compiler has been fixed to handle this scenario.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI81681

  • 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

    2020-08-24

  • Closed date

    2020-11-03

  • Last modified date

    2020-11-03

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

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

    IJ32578

Fix information

  • Fixed component name

    XL C/C++ LINUX

  • Fixed component ID

    5725C7310

Applicable component levels

[{"Line of Business":{"code":"LOB57","label":"Power"},"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"}]

Document Information

Modified date:
08 May 2021