IBM Support

LI75087: CLASS TEMPLATE NOT FINDING CLASS NAME

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • A class template takes a class type as it's first parameter, and
    an int as it's second parameter.  The int's default value is
    dependant on the class type of the first parameter (in the
    following testcase the sizeof function is used).  When
    instantiating the class template with a class type that is
    defined lower in the source, the compiler reports that the class
    is undefined.
    
    =====  Error   =====
    "test.C", line 1.31: 1540-1109 (S) The use of undefined class
    "SomeClass" is not valid.
    
    ===== TESTCASE =====
    template <class T, int myInt = sizeof(T)>
    class TestClass
    {};
    
    class SomeClass
    {};
    
    int main()
    {
     TestClass<SomeClass> test;
    }
    

Local fix

  • A forward definition of the class does not solve the issue.
    Moving the full class above the template class solves the
    problem.
    

Problem summary

  • USER AFFECTED:
    The problem may appear when a sizeof expression is used in a
    default template parameter, and that sizeof expression
    depends on the previous template parameters.
    
    PROBLEM DESCRIPTION:
    The compiler was resolving the name at the wrong location.
    

Problem conclusion

  • The compiler now uses the correct location to resolve
    the name.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI75087

  • Reported component name

    XL C/C++ RHEL52

  • Reported component ID

    5724U8310

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

    IZ50126

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

Fix information

  • Fixed component name

    XL C/C++ RHEL52

  • Fixed component ID

    5724U8310

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