[Bug c++/31881] New: inherited members invisible within nested class within templated class

ghood at psc dot edu gcc-bugzilla@gcc.gnu.org
Wed May 9 16:19:00 GMT 2007


Here is the code (nest.cc) that exhibits the error:

template<class X>
class A
{
public:
  class B
  {
  public:
    int i;
  };

  class C: public B
  {
  public:
    void f()
    {
      this->i;   // OK

      i;         // results in "error: ‘i’ was not declared in this scope"
                 //   even though i should be inherited from B
    }
  };
};

This code generate an error when compiled with "g++ -v -save-temps -c nest.cc"
on powerpc-linux-gnu using gcc 4.1.2, on i386-redhat-linux using gcc 4.1.0,
and on x86_64-redhat-linux using gcc 3.4.5.  This is somehow related to the
classes being templated because removing the template<class X> line will
eliminate the error.

It compiles without problem on i386-redhat-linux using gcc 3.2.2, on
x86_64-redhat-linux using PGI's pgCC 6.1.6, and on x86_64-redhat-linux using
Intel's icc 9.1.


-- 
           Summary: inherited members invisible within nested class within
                    templated class
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ghood at psc dot edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31881



More information about the Gcc-bugs mailing list