This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16067] New: scope resolution failure on base class members when derived and base classes are templates


gcc -v 
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.0/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--disable-libunwind-exceptions --host=i386-redhat-linux 
Thread model: posix 
gcc version 3.4.0 20040613 (Red Hat Linux 3.4.0-5) 
 
The following code works great in GCC 3.3.x but chokes in 3.4.0: 
 
template<class T> 
class A 
{ 
protected: 
  T t_; 
}; 
 
template<class T> 
class B: public A<T> 
{ 
public: 
  B() 
  { 
    t_; 
  } 
}; 
 
int main(int argc, char** argv) 
{ 
  B<int> b; 
} 
 
GCC 3.4.0 produces the following error on this code: 
bug.cc: In constructor `B<T>::B()': 
bug.cc:14: error: `t_' undeclared (first use this function) 
bug.cc:14: error: (Each undeclared identifier is reported only once for each 
function it appears in.) 
 
Simply changing the "t_;" line inside B's ctor to "A<T>::t_;" causes it to 
smarten up, but it doesn't seem like explicit scope resolution should be 
required in this context.  Also, the problem only appears when B's template 
argument is passed along to A.  If B explicitly specializes A it works fine 
too.

-- 
           Summary: scope resolution failure on base class members when
                    derived and base classes are templates
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aac76 at bellsouth dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]