This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/7347: Typedef'ing a protected typedef disallowed
- From: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 18 Jul 2002 08:06:48 -0000
- Subject: c++/7347: Typedef'ing a protected typedef disallowed
- Reply-to: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
>Number: 7347
>Category: c++
>Synopsis: Typedef'ing a protected typedef disallowed
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 18 01:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
gcc 3.2 pre of 2002-07-17
>Description:
A base class declares a protected typedef. A derived class declares a public typedef to the protected typedef of the base class, thus exposing the protected typedef of the base class publicly. Using it then fails:
--------------------------------------
template <int dim> class Base {
protected:
typedef int T;
};
template <int dim> class D : public Base<dim> {
public:
typedef typename Base<dim>::T T1;
D (T1 t);
};
D<2> d(1);
-----------------------------------
The messages reported are as follows:
x.cc: In instantiation of `D<dim>::D(typename Base<dim>::T)
[with int dim = 2]':
x.cc:13: instantiated from here
x.cc:3: error: `typedef int Base<2>::T' is protected
x.cc:10: error: within this context
This is a relatively new failure, it is in no released version of the compiler, and I did also not see it a couple of weeks ago.
To be honest, I am not really sure what the standard says about this, after all the typedef in the derived class references some protected type, but that would imply that typedefs build a long chain and access has to be checked at each stage; the other view would be that each typedef refers to a concrete type, rather than to a sequence of typedefs -- in this case the second typedef would just refer to "int", which certainly is not a protected member of the base class :-)
BTW: One thing that _is_ suspicious is that the problem only appears if the class is a template -- if it is a normal class, then everything compiles cleanly. I think that this incoherence qualifies as a bug in any case!
Regards
Wolfgang
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: