public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14930] New: Friend declaration ignored
@ 2004-04-13  0:02 austern at apple dot com
  2004-04-13  0:30 ` [Bug c++/14930] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: austern at apple dot com @ 2004-04-13  0:02 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-14 17:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-13  0:02 [Bug c++/14930] New: Friend declaration ignored austern at apple dot com
2004-04-13  0:30 ` [Bug c++/14930] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-04-15 22:50 ` reichelt at gcc dot gnu dot org
2004-06-06  3:38 ` giovannibajo at libero dot it
2004-06-12 21:47 ` mmitchel at gcc dot gnu dot org
2004-06-14 15:53 ` cvs-commit at gcc dot gnu dot org
2004-06-14 15:59 ` cvs-commit at gcc dot gnu dot org
2004-06-14 17:14 ` mmitchel at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).