IBM Support

LI74353: Incorrect undefined template error message

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The compiler may incorrectly issue an error message for some
    template code defined between a function declaration and the
    function definition where it is used.
    
    e.g.:
    $ cat tc.cxx
    struct A
    {
      static char foo();
      char bar(char c = foo());
    };
    
    struct B
    {
      B(int i) : t(i) {}
    
      int t;
    };
    
    template <class T>
    struct D : public B
    {
      D() : B(0) {}
    };
    
    char A::foo()
    {
      D<int> di;
      return 'a';
    }
    $ xlC -c tc.cxx
    "tc.cxx", line 17.7: 1540-0253 (S) This use of undefined class
    "B" is not valid.
    "tc.cxx", line 17.3: 1540-0700 (I) The previous message was
    produced while processing "D<int>::D()".
    "tc.cxx", line 22.10: 1540-0700 (I) The previous message was
    produced while processing "A::foo()".
    $
    

Local fix

  • Move the template code ahead of the function declaration.
    

Problem summary

  • A name lookup error may happen in the body of a template
    function where the required name is defined between the function
    declaration and the function definition.
    
    This happens for some source because the compiler incorrectly
    takes the location of the forward declaration to be the point of
    instantiation instead of location of function definition.
    
    If this problem occurs, the compiler will emit a name lookup
    error indicating an invalid us of an undefined class.
    

Problem conclusion

  • The compiler now handles this scenario correctly, and the
    invalid message is not emitted.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI74353

  • 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-03-31

  • Closed date

    2009-03-31

  • Last modified date

    2009-03-31

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

    IZ44565

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

    LI74425

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

Applicable component levels



Document information

More support for: XL C/C++

Software version: A.1

Reference #: LI74353

Modified date: 31 March 2009


Translate this page: