IBM Support

LI70872: TEMPLATE DATA TYPE NAME MISMATCH

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The testcase does not compile with XL C/C++ V7 compiler.
    > cat name_mismatch.cc
    #include <vector>
    
    using namespace std;
    
    class Foo
    {
            int bar1;
            int bar2;
    };
    
    class FooInfo
    {
    public:
       typedef class Foo   VectorType;
       typedef class Foo   NodeHandle;
    };
    
    typedef FooInfo   FooMesh;
    
    template <class Space, class Centering, class Value>
    class BC{
    public:
       typedef std::vector<Value>                 StorageType;
    
       BC(const Space& space,
          const std::vector<Centering>& elements,
          const int dataLength) {}
    };
    template<class Space2>
    class BarBC: public BC<Space2,
                                typename Space2::NodeHandle,
                                typename Space2::VectorType>
    {
    public:
    
       typedef typename Space2::NodeHandle NodeHandle;
       typedef typename Space2::VectorType VectorType;
    
       BarBC(const Space2& space,
                  const std::vector<NodeHandle>& nodes);
    };
    template<class Space3>
    BarBC<Space3>::
    BarBC(const Space3& space,
              const std::vector<NodeHandle>& nodes):
       BC<Space3, NodeHandle, VectorType>(space, nodes, 1)
    {
    
       return;
    }
    template class BarBC<FooMesh>;
    .
    COMPILE COMMAND:            xlC -g name_mismatch.cc
    "name.cc", line 47.1: 1540-0130 (S) "Space2" is not declared.
    "name.cc", line 56.16: 1540-0700 (I) The previous message was
    produced while pro
    cessing "@ctor".
    "name.cc", line 56.16: 1540-0700 (I) The previous message was
    produced while pro
    cessing "class BarBC<FooInfo>".
    "name.cc", line 47.1: 1540-0130 (S) "Space2" is not declared.
    "name.cc", line 32.7: 1540-0700 (I) The previous message was
    produced while proc
    essing "@ctor".
    "name.cc", line 32.7: 1540-0700 (I) The previous message was
    produced while proc
    essing "class BarBC<FooInfo>".
    .
    Workaround: If the template data type names 'Space2' and
                'Space3' are renamed to 'Space' the problem goes
                away. If the "const std::vector<NodeHandle>& nodes"
                parameter is removed, the problem also goes away.
    Expected output: The testcase should pass the compilation phase.
    

Local fix

Problem summary

  • same as submitter's text
    

Problem conclusion

  • Users Affected: Users who declare member functions of template
      out-of-line, specifically where the function parameters make
      a reference to a template-dependent typedef or a template
      dependent default argument.
    Problem Description: The compiler was incorrectly referencing
      a template parameter name available only in the scope of the
      containing class from the out-of-line definition. This
      caused compiler errors for undeclared template parameters.
    Workaround: To work around the problem try giving the template
      parameters in the out-of-line definition the same names as
      the ones for the containing class. If that does not work,
      define the member function inside the containing class so
      there is only 1 set of template parameters.
    Expected Errors: Errors indicating a template parameter name is
      undeclared in the context of an out-of-line definition of a
      member function of a template class.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI70872

  • 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-22

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

    IY67314

  • 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