IBM Support

IZ86229: MEMBER NOT DECLARED AS A TEMPLATE ERROR

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Compiling the following test case TemplateBug.cpp with xlC emits
    error:
    
    "TemplateBug.cpp", line 19.1: 1540-1174 (S) The member "template
    const
    Bar<T,0,1> &Bang(const Bar &)" is not declared as a template in
    its
    containing class definition.
    
    
    
    ===== TESTCASE:
    > cat TemplateBug.cpp
    
    enum Foo { Alpha, Beta };
    
    template<typename T, Foo F, Foo G>
    class Bar;
    
    // Partial specialization of Bar
    template<typename T>
    class Bar<T,Alpha,Beta>
    {
    public:
        const Bar<T,Alpha,Beta>&
        Bang( const Bar<T,Alpha,Beta>& bar );
    };
    
    // Implementation of member function of partially specialized
    Bar
    template<typename T>
    const Bar<T,Alpha,Beta>&
    Bar<T,Alpha,Beta>::Bang
    ( const Bar<T,Alpha,Beta>& bar )
    { return bar; }
    
    // Explicit instantiation
    template class Bar<double,Alpha,Beta>;
    

Local fix

  • Changing const Bar<T,Alpha,Beta>& to void makes it pass. for
    example:
    
    
    >cat TemplateNoBug.cpp
    
    enum Foo { Alpha, Beta };
    
    template<typename T, Foo F, Foo G>
    class Bar;
    
    // Partial specialization of Bar
    template<typename T>
    class Bar<T,Alpha,Beta>
    {
    public:
        void
        Bang( const Bar<T,Alpha,Beta>& bar );
    };
    
    // Implementation of member function of partially specialized
    Bar
    template<typename T>
    void
    Bar<T,Alpha,Beta>::Bang
    ( const Bar<T,Alpha,Beta>& bar )
    { }
    
    // Explicit instantiation
    template class Bar<double,Alpha,Beta>;
    

Problem summary

  • PROBLEM DESCRIPTION:
    The compiler is failing to match the out-of-line definition of
    a template member with a non-type parameter which is an
    enumeration.
    
    USERS AFFECTED:
    The problem affects users of template classes with non-type
    parameters of enumeration type.
    

Problem conclusion

  • The compiler was incorrectly matching the out-of-line member
    when a non-type template parameter was an enumeration type.
    The problem is fixed now.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ86229

  • Reported component name

    XL C++ AIX

  • Reported component ID

    5724U8100

  • Reported release

    A10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2010-10-05

  • Closed date

    2010-10-05

  • Last modified date

    2010-10-05

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

    LI75501

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

Fix information

  • Fixed component name

    XL C++ AIX

  • Fixed component ID

    5724U8100

Applicable component levels

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

Document Information

Modified date:
06 October 2021