Bug 16617

Summary: Fail to do access checking correctly for non-dependent qualified-id
Product: gcc Reporter: Kriang Lerdsuwanakij <lerdsuwa>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: fang, gcc-bugs, giovannibajo, reichelt, rguenth, sutambe
Priority: P2 Keywords: accepts-invalid
Version: 4.0.0   
Target Milestone: ---   
URL: http://gcc.gnu.org/ml/gcc-patches/2005-05/msg01992.html
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-04-22 05:12:13
Bug Depends on:    
Bug Blocks: 13495    

Description Kriang Lerdsuwanakij 2004-07-18 13:52:32 UTC
This is a spin out of a problem mentioned in PR13092.
The following testcase shouldn't compile because only
fr<int> is friend of class D.  But we are accessing
protected members from fr<char>.  GCC 3.4, 3.5 fail
to diagnose it.  Earlier GCC don't handle this properly
(checking access while parsing the template fr<T> which
is too early.)  So it's not a regression.


// Two-phase name lookup for address of member:
// Protected member access

class B
{
  protected:
  int i;			// { dg-error "protected" }
};

template <class T> void fr ();

class D2 : public B
{
  friend void fr<int> ();
};

template<int B::*> struct X
{};

template <class T> void fr ()
{
  X<&B::i> x1;			// { dg-error "context" }
  X<&D2::i> x2;			// { dg-error "context" }
}

template void fr<char>();	// { dg-error "instantiated" }
Comment 1 Wolfgang Bangerth 2004-07-28 13:48:57 UTC
Confirmed. 
W. 
Comment 2 Kriang Lerdsuwanakij 2004-12-12 12:42:31 UTC
Got it.  The target for this fix is GCC 4.1.
Comment 3 Kriang Lerdsuwanakij 2005-01-12 10:50:37 UTC
May be fixed together with PR19311.
Comment 4 Kriang Lerdsuwanakij 2005-04-23 15:30:17 UTC
This is a stage 2 project.  Likely to be fixed in a month or two.
Comment 5 Kriang Lerdsuwanakij 2005-05-19 17:09:02 UTC
Patch using new approach for 4.1:
  http://gcc.gnu.org/ml/gcc-patches/2005-05/msg01992.html
(Note this is part 4 in a series, earlier parts are also required)
Comment 6 Kriang Lerdsuwanakij 2005-06-07 14:58:59 UTC
Patch withdrawn due to overlooking default function argument and default
template argument. No nice solution is found yet.
Comment 7 Andrew Pinski 2009-04-29 07:05:07 UTC
*** Bug 33934 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2009-04-29 07:05:41 UTC
*** Bug 24118 has been marked as a duplicate of this bug. ***