This is the mail archive of the gcc-patches@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]

Re: [C++ PATCH] Fix PR4802, 5387


[Oops. I forget to CC:gcc-patches list.  Actual reply is below.]

Gabriel Dos Reis wrote:
>
> Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> writes:
>
> [...]
>
> | + // PR c++/5387
> | + // Enforcing access of typename type.
> | +
> | + template <class T> struct A {
> | +   typename T::X x;                    // { dg-error "this context" }
> | +   int f() { return T::i; }            // { dg-error "this context" }
> | + };
>
> That is not an error when A<> is explicitly instantiated:
>
> 17.4.2/8
>
>   The usual access checking rules do not apply to names used to
>   specify explicit instantiations. [Note: In par-ticular, the template
>   arguments and names used in the function declarator (including
>   parameter types, return types and exception specifications) may be
>   private types or objects which would normally not be accessible and
>   the template may be a member template or member function which would
>   not normally be accessible. ]
>
> -- Gaby

I think that's only for explicit instantiation of the class itself, i.e.
in
  template <class T> class A {
    typedef int I; // private
    template <class T> void f(T, I); // private function
  };
  template void A<int>::f(char, I); // Ok, even f, I are private

It doesn't involve the 'typename' problem addressed by my patch.

--Kriang
--- Begin Message ---
Gabriel Dos Reis wrote:
> 
> Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> writes:
> 
> [...]
> 
> | + // PR c++/5387
> | + // Enforcing access of typename type.
> | +
> | + template <class T> struct A {
> | +   typename T::X x;                    // { dg-error "this context" }
> | +   int f() { return T::i; }            // { dg-error "this context" }
> | + };
> 
> That is not an error when A<> is explicitly instantiated:
> 
> 17.4.2/8
> 
>   The usual access checking rules do not apply to names used to
>   specify explicit instantiations. [Note: In par-ticular, the template
>   arguments and names used in the function declarator (including
>   parameter types, return types and exception specifications) may be
>   private types or objects which would normally not be accessible and
>   the template may be a member template or member function which would
>   not normally be accessible. ]
> 
> -- Gaby

I think that's only for explicit instantiation of the class itself, i.e.
in
  template <class T> class A {
    typedef int I; // private
    template <class T> void f(T, I); // private function
  };
  template void A<int>::f(char, I); // Ok, even f, I are private

It doesn't involve the 'typename' problem addressed by my patch.

--Kriang
--- End Message ---

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