[Bug c++/11759] New: Template base class members are inaccessible

pgonzalez at bluel dot com gcc-bugzilla@gcc.gnu.org
Fri Aug 1 07:32:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Template base class members are inaccessible
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pgonzalez at bluel dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-arm-elf

The attached code compiles without problems on GCC 3.3.
On gcc-3.4-20030730, it produces the following errors:

  test.cpp: In member function `void TDynArrayBase<T>::alloc(int)':
  test.cpp:18: error: `count' undeclared (first use this function)
  test.cpp:18: error: (Each undeclared identifier is reported only once for 
each 
     function it appears in.)
  test.cpp: In member function `bool TDynArrayBase<T>::isEmpty() const':
  test.cpp:25: error: there are no arguments to `getCount' that depend on a 
     template parameter, so a declaration of `getCount' must be available
  test.cpp:25: error: (if you use `-fpermissive', G++ will accept your code, 
but 
     allowing the use of an undeclared name is deprecated)

The errors go away if you remove the "#define OLD_GCC" line.

____________________________

#define OLD_GCC

//---------------------------------------------------------------------------
template <class T>
class TArrayBase {
protected:
  int count;
public:
  int getCount() const { return count; }
};

//---------------------------------------------------------------------------
template <class T>
class TDynArrayBase : public TArrayBase<T> {
public:
  void alloc(int count_) { 
#ifdef OLD_GCC
    count = count_; 
#else
    TArrayBase<T>::count = count_; 
#endif
  }
  bool isEmpty() const {
#ifdef OLD_GCC
    return getCount() != 0;
#else
    return TArrayBase<T>::getCount() != 0;
#endif
  }
};



More information about the Gcc-bugs mailing list