public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "austern at apple dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/14930] New: Friend declaration ignored
Date: Tue, 13 Apr 2004 00:02:00 -0000	[thread overview]
Message-ID: <20040412225446.14930.austern@apple.com> (raw)

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


             reply	other threads:[~2004-04-12 22:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-13  0:02 austern at apple dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040412225446.14930.austern@apple.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).