Bug 56248 - [DR 580] access checking of template parameters done too early
Summary: [DR 580] access checking of template parameters done too early
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-02-07 23:34 UTC by Jonathan Wakely
Modified: 2019-07-07 03:19 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-07-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2013-02-07 23:34:34 UTC
This code based on the example in [class.access]/6 is rejected:

class A {
  typedef int I; // private member
  template<int> struct Q;
  template<int> friend struct R;
protected:
  struct B { };
};
template<A::I> struct A::Q { };
template<A::I> struct R { };
struct D: A::B, A { };


t.cc:2:15: error: ‘typedef int A::I’ is private
   typedef int I; // private member
               ^
t.cc:8:13: error: within this context
 template<A::I> struct A::Q { };
             ^
t.cc:2:15: error: ‘typedef int A::I’ is private
   typedef int I; // private member
               ^
t.cc:9:13: error: within this context
 template<A::I> struct R { };
             ^
t.cc:6:10: error: ‘struct A::B’ is protected
   struct B { };
          ^
t.cc:10:14: error: within this context
 struct D: A::B, A { };
              ^

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#580 clarifies that access checking of the template parameters should be delayed until the context is known.