IBM Support

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

    LI75597

  • 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

    2010-07-28

  • Closed date

    2010-07-28

  • Last modified date

    2010-07-28

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

    IZ67449

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724U8300

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:
17 October 2021