14930 – [3.3/3.4/4.0 Regression] Friend declaration ignored (original) (raw)

Description Matt Austern 2004-04-12 22:54:46 UTC

Here's the code sample: template class Point;

template<> class Point { friend class Plane; double v; };

struct Plane { double get(const Point& p); };

double Plane::get(const Point &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::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.