IBM Support

IZ67449: MISLEADING TEMPLATE ERROR MESSAGE

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The following test case compiles with an error message on V10.1
    xlC.
    
    
    "test1.cpp", line 7.15: 1540-0236 (S) The constructor
    initializer is
    unexpected.  All bases and members have been initialized.
    
    But it compiles clean on V9, V8, and V7 xlC.
    
    It also compiles clean on Sun's CC compilers.
    
    With g++, the test case gives another error:
    
    test1.cpp: In constructor `B::B(int)':
    test1.cpp:7: error: class `B' does not have any field named `A'
    
    Is the test case ill-formed?
    
    But nonetheless, the error message from XLC++ is very
    confusing.
    
    
    ===== TESTCASE:
    //cat test1.cpp:
    
    template <class T>
    struct A {
      A () { }
      A (const T&) { }
    };
    struct B : public A<int> {
      B (int v) : A(v) { } // diagnostic here is very misleading
    };
    B f () {
      return 5;
    }
    

Local fix

  • Change
    B (int v) : A(v) { } // diagnostic here is very misleading
    
    to:
    B (int v) : A<int>(v) { }
    

Problem summary

  • USER AFFECTED:
    Users attempting to use the name of template base class
    without template arguments in the derived class
    - specifically in a constructor initializer list.
    
    PROBLEM DESCRIPTION:
    The behaviour for injected names has been clarified
    in the C++ standard so that this syntax is no longer
    permitted, however the compiler message is not useful.
    

Problem conclusion

  • Message now emitted is:
    'a.cpp', line 7.15: 1540-1113
    (S) The class template name 'A' must be followed by a < in this
    context.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IZ67449

  • 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

    2009-12-31

  • Closed date

    2010-02-24

  • Last modified date

    2010-03-12

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

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

    LI75566 LI75597

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