IBM Support

LI70894: Compile error given for valid templates code

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • $ cat t.cpp
    #include <iostream>
    template <class T>
    struct Confuse {
       typedef T ScalarType;
    };
    template <class T>
    struct Forward {
       typedef typename Confuse<T>::ScalarType ScalarType;
    };
    template <class T>
    class Vector{
    };
    template <class T>
    class Array{
       typedef typename Confuse<T>::ScalarType ScalarType;
       public:
       void mf(const Vector<ScalarType> &);
    };
    template <class T>
    void Array<T>::mf(const Vector<ScalarType> &){ std::cout <<
    "Hello" <<
    std::endl;}
    template class Array<char>;
    template void Array<int>::mf(const Vector<
    Confuse<int>::ScalarType >
    &);
    .
    $ xlC -c t.cpp
    "t.cpp", line 27.15: 1540-0092 (S) An explicit instantiation
    must instantiate a
    template function definition.
    

Local fix

Problem summary

  • same as submitter's text
    

Problem conclusion

  • USERS AFFECTED:  Users of class templates with member
     functions defined out-of-line, specifically where a typedef
     member of the template class is referenced in a template
     argument in the return type or argument list of the out-of-line
     definition.
    PROBLEM DESCRIPTION: The compiler was incorrectly unwinding
     the typedef in the template argument which caused the
     out-of-line definition to fail to match the declaraction
     inside its containing class.
    WORKAROUND:   To work around the problem, move the definition of
     the member function inside the class.
    EXPECTED ERRORS:  With the -qtmplparse=error option, users will
     see a message that the member being defined out-of-line was
     not declared as a member of its containing class.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI70894

  • Reported component name

    XL C/C++ SLES9

  • Reported component ID

    5724K7700

  • Reported release

    700

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2005-08-22

  • Closed date

    2005-08-22

  • Last modified date

    2005-08-25

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

    IY70330

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

Fix information

  • Fixed component name

    XL C/C++ SLES9

  • Fixed component ID

    5724K7700

Applicable component levels

  • R700 PSY

       UP

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

Document Information

Modified date:
14 October 2021