[Bug c++/14930] New: Friend declaration ignored
austern at apple dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 13 00:02:00 GMT 2004
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
More information about the Gcc-bugs
mailing list