Bug 56248 (cwg580) - [DR 580] access checking of template parameters done too early
Summary: [DR 580] access checking of template parameters done too early
Status: NEW
Alias: cwg580
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
: 111872 (view as bug list)
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2013-02-07 23:34 UTC by Jonathan Wakely
Modified: 2024-04-04 06:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-04-03 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.
Comment 1 Andrew Pinski 2024-04-04 06:22:25 UTC
*** Bug 111872 has been marked as a duplicate of this bug. ***