IBM Support

LI75118: C++ TEMPLATE NAME LOOKUP ERROR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Compiler incorrectly emits the following error messages for the
    testcase provided below:
    
    ===== COMPILE COMMAND:
    xlC_r -c -qlanglvl=extended 89717.7TD.000bug.cpp
    
    
    ===== TESTCASE:
    $ cat 89717.7TD.000bug.cpp
    ///Notes
    ///-----
    // 0. Compile with:
    /bb/util/version10-062009/usr/vacpp/bin/xlC_r -c bug.cpp
    // 1. Order is important.  'MySharedObj' and 'InplaceRepl' must
    come before
    //    'TestArg' and 'TestType' to reproduce the problem.
    // 2. 'If you replace 'InplaceRepl<TYPE>' inside 'MySharedObj'
    with just
    //    'TYPE *' and construct 'TYPE' directly, the problem goes
    away.
    // 3. In 'TestArg', replace the constructor with two
    constructors that do not
    //    have default arguments, the problem goes away.
    
    template <class TYPE>
    class InplaceRepl {
        TYPE  d_instance;
      public:
        template <class A1> InplaceRepl(const A1& a1);
    };
    
    template <class TYPE>
    class MySharedObj {
        InplaceRepl<TYPE> *d_rep_p;
      public:
        template <class A1> MySharedObj(const A1& a1);
    };
    
    template <class TYPE>
    template <class A1>
    MySharedObj<TYPE>::MySharedObj(const A1& a1)
    {
        typedef InplaceRepl<TYPE> Rep;
        Rep *rep = new Rep(a1);
    }
    
    template <class TYPE>
    template <class A1>
    InplaceRepl<TYPE>::InplaceRepl(const A1& a1)
    : d_instance(a1)
    {
    }
    
    //--------------------------------------------------------------
    ---------------
    
    class TestArg {
        int *d_allocator_p;
        int  d_value;
      public:
        TestArg(int value, int *allocator = 0);
        TestArg(const TestArg& original, int *allocator = 0);
    };
    
    class TestType {
        TestArg  d_a1;
      public:
        TestType(int *allocator = 0, TestArg a1 = 1);
    };
    
    int *Z1;
    MySharedObj<TestType> x(Z1);
    
    
    ===== ACTUAL OUTPUT:
    
    "89717.7TD.000bug.cpp", line 36.3: 1540-0215 (S) The wrong
    number of arguments have been specified for
    "TestArg::TestArg(int, int *)".
    "89717.7TD.000bug.cpp", line 36.3: 1540-1205 (I) The error
    occurred while converting to parameter 2 of
    "TestType::TestType(int *, TestArg)".
    "89717.7TD.000bug.cpp", line 35.1: 1540-0700 (I) The previous
    message was produced while processing
    "InplaceRepl<TestType>::InplaceRepl(int * const &)".
    "89717.7TD.000bug.cpp", line 30.16: 1540-0700 (I) The previous
    message was produced while processing
    "MySharedObj<TestType>::MySharedObj(int * const &)".
    "89717.7TD.000bug.cpp", line 57.23: 1540-0700 (I) The previous
    message was produced while processing "x".
    
    
    ===== EXPECTED OUTPUT:
    Compiles clean.
    

Local fix

  • N/A
    

Problem summary

  • This problem occurs when 2 (or more) default function arguments
    are required for a constructor call in a constructor initializer
    list for a template class.
    The point of instantiation for the second default argument was
    invalid causing a name lookup error.
    

Problem conclusion

  • The instantiation point of the default is set correctly.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75118

  • Reported component name

    XL C/C++ SLES10

  • Reported component ID

    5724U8300

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-12-01

  • Closed date

    2009-12-01

  • Last modified date

    2009-12-01

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

    IZ56244

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"A.1","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
14 October 2021