This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/8389: Cannot access protected member in base class
- From: dv at vollmann dot ch
- To: gcc-gnats at gcc dot gnu dot org
- Cc: dv at vollmann dot ch
- Date: Tue, 29 Oct 2002 03:01:10 +0100
- Subject: c++/8389: Cannot access protected member in base class
>Number: 8389
>Category: c++
>Synopsis: Cannot access protected member in base class
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Oct 28 18:06:29 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Detlef Vollmann
>Release: 3.3 20021027 (experimental)
>Organization:
vollmann engineering gmbh
>Environment:
System: Linux dwarf 2.4.3-XFS #7 Mon Aug 6 18:43:20 CEST 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /pdsrc/gcc/cvs/gcc/configure --program-suffix=-test --prefix=/local/gcc-test --enable-shared --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++
>Description:
For the attached program, g++ gives the error message:
test.cc: In member function `Derived<T> Derived<T>::f() const [with T = char]':
test.cc:30: instantiated from here
test.cc:6: error: `typedef int Base<char>::Type' is protected
test.cc:23: error: within this context
>How-To-Repeat:
just compile attached source (g++ -c test.cc)
>Fix:
//test.cc:
template <class>
class Base
{
protected:
typedef int Type;
};
template <class T>
class Derived : public Base<T>
{
public:
typedef Base<T> BaseT;
typedef typename BaseT::Type Type;
template <class Arg>
Derived(Arg a, const Type& t = Type())
{ }
Derived f() const
{
return Derived(i);
}
int i;
};
template class Derived<char>;
>Release-Note:
>Audit-Trail:
>Unformatted: