Bug 56248 (cwg580)

Summary: [DR 580] access checking of template parameters done too early
Product: gcc Reporter: Jonathan Wakely <redi>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: daniel.kruegler, jlame646, webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 4.8.0   
Target Milestone: ---   
See Also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90324
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2024-04-03 00:00:00
Bug Depends on:    
Bug Blocks: 94404    

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. ***