IBM Support

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

    IZ44565

  • Reported component name

    XL C++ AIX

  • Reported component ID

    5724U8100

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-02-23

  • Closed date

    2009-03-19

  • Last modified date

    2009-04-28

Fix information

  • Fixed component name

    XLC C++ AIX

  • Fixed component ID

    5724S7100

Applicable component levels

  • R900 PSY U825400

       UP C



Document information

More support for: XL C/C++

Software version: 9.0

Reference #: IZ44565

Modified date: 28 April 2009


Translate this page: