IBM Support

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

    IZ48172

  • Reported component name

    XLC C++ AIX

  • Reported component ID

    5724S7100

  • Reported release

    900

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2009-04-02

  • Closed date

    2009-06-26

  • Last modified date

    2009-11-26

Fix information

  • Fixed component name

    XLC C++ AIX

  • Fixed component ID

    5724S7100

Applicable component levels

[{"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Product":{"code":"SSJT9L","label":"XL C\/C++"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.0","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
26 November 2009