Bug 19258 - [3.4 Regression] Incorrect access check for default argument
Summary: [3.4 Regression] Incorrect access check for default argument
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.4
Assignee: Kriang Lerdsuwanakij
Keywords: patch, rejects-valid
Depends on:
Reported: 2005-01-04 19:38 UTC by Matt Austern
Modified: 2005-01-19 14:47 UTC (History)
1 user (show)

See Also:
Host: powerpc-apple-darwin7.7.0
Target: powerpc-apple-darwin7.7.0
Build: powerpc-apple-darwin7.7.0
Known to work:
Known to fail:
Last reconfirmed: 2005-01-05 10:05:33


Note You need to log in before you can comment on or make changes to this bug.
Description Matt Austern 2005-01-04 19:38:01 UTC
The following code
  class X {
    template<class T> friend int ff(T*, int y=anX.x) { return y; }
    int f() { return ff(&anX); }
    static X anX;
    int x;
  X dummy;
gives an error message with mainline:
  foo.cc:6: error: 'int X::x' is private
  foo.cc:3: error: within this context	
That error message doesn't make sense.  The only relevant contexts are that of X::f (in which x may be 
accessed, since X has access to its own members) and that of ff (which has access because it is a friend 
of X.)  The analogous non-template case compiles correctlly.

This is a regression from 3.3.
Comment 1 Andrew Pinski 2005-01-04 19:48:44 UTC
: Search converges between 2003-01-02-trunk (#161) and 2003-01-10-trunk (#162).

Note with 3.4.x, we get a different error message:
input.cc:2: error: `anX' was not declared in this scope

The error message changed betwen 20040709 and 20040712.
Comment 2 Kriang Lerdsuwanakij 2005-01-05 10:05:33 UTC
Got it
Comment 3 Kriang Lerdsuwanakij 2005-01-05 14:15:59 UTC
Patch for mainline submitted:

For 3.4 branch, the parser is still broken with respect to default
argument parsing in such friend declaration.  Some more work is
required there.
Comment 4 CVS Commits 2005-01-06 15:41:48 UTC
Subject: Bug 19258

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2005-01-06 15:41:34

Modified files:
	gcc/cp         : ChangeLog pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/lookup: friend6.C 

Log message:
	PR c++/19258
	* pt.c (push_access_scope): Handle friend defined in class.
	(pop_access_scope): Likewise.
	* g++.dg/lookup/friend6.C: New test.


Comment 5 Kriang Lerdsuwanakij 2005-01-06 15:46:20 UTC
Fixed in the mainline.
Comment 6 Kriang Lerdsuwanakij 2005-01-18 14:40:21 UTC
Patch for 3.4 here:

Comment 8 Kriang Lerdsuwanakij 2005-01-19 14:47:21 UTC
Fixed in 3.4 branch.