LI76952: COMPILER ERROR WITH TEMPLATES AND NAMESPACES

Subscribe

You can track all active APARs for this component.

APAR status

  • Closed as program error.

Error description

  • The following test case fails to compile successfully using the
    following options:
    
    
    ===== COMPILE COMMAND:
    mpixlcxx_r -DNAMESPACE test.cc
    
    
    ===== TESTCASE:
    $ cat test.cc
    #include <iostream>
    using namespace std;
    
    #ifdef NAMESPACE
    namespace Bar {
    #endif
    
    template< class Foo, int N, template <class,int> class C>
    class Odd {
    public:
     // A constructor
     Odd() { }
    };
    
    // The weirdo class
    template< class Foo, int N>
    class CuriouslyRecursive : public Odd<Foo, N,
    CuriouslyRecursive>
    {
    public:
      // A constructor
      CuriouslyRecursive() { }
    };
    
    
    // A random class to use for the Foo templates
    class RandomClass
    {
    public:
      RandomClass() {}
    };
    
    #ifdef NAMESPACE
    }
    using namespace Bar;
    #endif
    
    int main(int argc, char *argv[])
    {
      CuriouslyRecursive<RandomClass,4> try_this;
    }
    $
    
    
    
    ===== ACTUAL OUTPUT:
    $ mpixlcxx_r test.cc -DNAMESPACE
    "testprog.cc", line 17.7: 1540-0716 (S) The template argument
    "Bar::CuriouslyRecursive" does not match the template parameter
    "template class C".
    "testprog.cc", line 17.7: 1540-0716 (S) The template argument
    "Bar::CuriouslyRecursive<Bar::RandomClass,4>" does not match the
    template parameter "template class C".
    "testprog.cc", line 39.37: 1540-0700 (I) The previous message
    was produced while processing "class
    Bar::CuriouslyRecursive<Bar::RandomClass,4>".
    "testprog.cc", line 37.5: 1540-0700 (I) The previous message was
    produced while processing "main(int, char *[])".
    $
    
    
    ===== EXPECTED OUTPUT:
    Clean compile.
    

Local fix

  • Avoid adding the class in a namespace if possible
    

Problem summary

  • USERS AFFECTED:
    When a class is defined outside its namespace or outside its
    enclosing class, the scope used to lookup the base class names
    might be incorrect causing a name lookup error.
    
    
    PROBLEM DESCRIPTION:
    Name lookup for base class in the wrong scope for namespace or
    nested class name.
    This leads to a compile time error.
    

Problem conclusion

  • The problem has been fixed.
    

Temporary fix

Comments

APAR Information

  • APAR number

    LI76952

  • Reported component name

    XL C/C++ FOR BG

  • Reported component ID

    5799AG100

  • Reported release

    C10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-08-07

  • Closed date

    2012-11-23

  • Last modified date

    2012-11-23

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

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

Fix information

  • Fixed component name

    XL C/C++ FOR BG

  • Fixed component ID

    5799AG100

Applicable component levels

  • RC10 PSY

       UP



Rate this page:

(0 users)Average rating

Document information


More support for:

XL C/C++ for Blue Gene/Q
Compiler

Software version:

12.1

Reference #:

LI76952

Modified date:

2012-11-23

Translate my page

Machine Translation

Content navigation