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. -- Summary: Incorrect access check for default argument Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: austern at apple dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: powerpc-apple-darwin7.7.0 GCC host triplet: powerpc-apple-darwin7.7.0 GCC target triplet: powerpc-apple-darwin7.7.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19258