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]

c++/7347: Typedef'ing a protected typedef disallowed


>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:


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