IBM Support

LI74781: Lookup error with templates and inheritance

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • The compiler is failing to complete a name lookup in some
    template classes that depend on inheritance relationships in the
    template parameters, which are also template classes.
    
    Example:
    $ cat small2.cxx
    template <class ZZ, class ZZout=ZZ>
    struct ZBoss { };
    
    template<template<class> class V, class T>
    struct Doer : T {
    };
    
    struct NoBoss {
      template<class Z> struct P{ };
    };
    
    template <typename A> struct Va { };
    
    template<class ZZ, class V = NoBoss>
    struct TheGuy {
      // (S) 1540-0716
      Doer<V::template P, ZBoss<ZZ> > vp0;
      Va<int> stuff;
    };
    
    // (S) 1540-0138
    template class TheGuy<int,NoBoss>;
    $ xlC -c small2.cxx
    "small2.cxx", line 17.8: 1540-0716 (S) The template argument
    "V::P<>" does not match the template parameter "template class
    V".
    "small2.cxx", line 22.16: 1540-0138 (S) The undefined template
    "TheGuy" must not be explicitly instantiated.
    $
    

Local fix

  • Provide an explicit instantiation of the template base class in
    question.
    
    Example:
    $ cat wa2.cxx
    template <class ZZ, class ZZout=ZZ>
    struct ZBoss { };
    
    template<template<class> class V, class T>
    struct Doer : T {
    };
    
    struct NoBoss {
      template<class Z> struct P{ };
    };
    
    template <typename A> struct Va { };
    template struct Va<int>; // explicit instantiation
    
    template<class ZZ, class V = NoBoss>
    struct TheGuy {
      Doer<V::template P, ZBoss<ZZ> > vp0;
      Va<int> stuff;
    };
    
    template class TheGuy<int,NoBoss>;
    $ xlC -c wa2.cxx
    $
    

Problem summary

  • USER AFFECTED:
    The problem appears when a template qualified name is
    specified without arguments in order to match a template
    template parameter.
    
    PROBLEMDESCRIPTION:
    A problem with name lookup was causing this name to
    be incorrectly resolved resulting in an error in matching
    the template template parameter.
    

Problem conclusion

  • The name lookup issue has been resolved.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI74781

  • Reported component name

    XL C/C++ SLES10

  • Reported component ID

    5724S7300

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-07-29

  • Closed date

    2009-07-29

  • Last modified date

    2009-07-29

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

    IZ48172

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

Fix information

  • Fixed component name

    XL C/C++ SLES10

  • Fixed component ID

    5724S7300

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":"9.0","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
16 October 2021