This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14930] New: Friend declaration ignored
- From: "austern at apple dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Apr 2004 22:54:48 -0000
- Subject: [Bug c++/14930] New: Friend declaration ignored
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here's the code sample:
template<typename T> class Point;
template<> class Point<double> {
friend class Plane;
double v;
};
struct Plane {
double get(const Point<double>& p);
};
double Plane::get(const Point<double> &p) { return p.v; }
Compiling this gives an error message:
foo.cc: In member function `double Plane::get(constPoint<double>&)':
foo.cc:7: error: `double Point<double>::v' is private
foo.cc:14: error: within this context
I can't find any justification for this error. The only odd thing about this code sample is that the friend
declaration is the first time we have encountered the name "Plane", but this is legal. It even appears in
one of the examples in clause 11.4 of the standard.
Note that this error is very delicate. It goes away in the non-template case and it goes away if we use
an impliict instantiation instead of an explicit specialization.
--
Summary: Friend declaration ignored
Product: gcc
Version: 3.5.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.3.0
GCC host triplet: powerpc-apple-darwin7.3.0
GCC target triplet: powerpc-apple-darwin7.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14930