public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "MichieldeB at aim dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/45942] class will not get friends with another class
Date: Fri, 08 Oct 2010 15:43:00 -0000	[thread overview]
Message-ID: <20101008154300.mQ_0WsWLvdG6byh-lnt8ZaCmm1bV11E5B_jI97NQkhs@z> (raw)
In-Reply-To: <bug-45942-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45942

--- Comment #9 from Michiel <MichieldeB at aim dot com> 2010-10-08 15:43:13 UTC ---
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #2)
> > > This code is not valid, G++ is correct to reject it.
> > 
> > Please explain why the code is invalid, and do not click "Resolved invalid"
> > until ClassB is a friend of ClassA.
> 
> You reported an invalid bug, so I rejected it.
> It's not my job to teach you C++ but here you go:
> 
> template <class T, int C> class A;
> 
> template <class T, int C, A<T,C> &a> class B;
> 
> template <class T, int C> class A
> {
>   template <class X, int Y, A<X,Y>&> friend class B;
> };
> 
> 
> That makes B<X,Y,A<X,Y>&> a friend of A
> 
> Your original example is invalid for the reason the compiler gave, the syntax
> you tried to use declares a partial specialization, which is not allowed in a
> friend declaration.  That's how C++ works, I don't make the rules.

I really tried everything, but I have to admit I missed that one. Sorry. But
you have to admit that it is a rather unnatural way to make friends. 
Furthermore, the third parameter Z is missing (I would prefer A<X,Y>&Z), but
that does not seem to be a problem for the compiler.

Thus it seems that the bug is that c++ is designed is such a way that it gives
error messages which are incorrect.

If you would have followed the title of my bug report immediately instead of
saying that is was invalid, then the discussion would have been unnecessary.

Now it is still odd that the first attempt gives an error so lately. The
template precompiler counts three arguments and the template instantiator
counts one, which is not very consistent.


  parent reply	other threads:[~2010-10-08 15:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 13:42 [Bug c++/45942] New: " MichieldeB at aim dot com
2010-10-08 14:41 ` [Bug c++/45942] " redi at gcc dot gnu.org
2010-10-08 14:46 ` redi at gcc dot gnu.org
2010-10-08 14:51 ` MichieldeB at aim dot com
2010-10-08 14:58 ` MichieldeB at aim dot com
2010-10-08 15:03 ` paolo.carlini at oracle dot com
2010-10-08 15:08 ` redi at gcc dot gnu.org
2010-10-08 15:12 ` MichieldeB at aim dot com
2010-10-08 15:36 ` redi at gcc dot gnu.org
2010-10-08 15:43 ` MichieldeB at aim dot com [this message]
2010-10-08 15:59 ` redi at gcc dot gnu.org
2010-10-08 16:09 ` MichieldeB at aim dot com
2010-10-09 13:02 ` MichieldeB at aim dot com
2010-10-09 13:38 ` MichieldeB at aim dot com
2010-10-09 18:08 ` redi at gcc dot gnu.org
2010-10-09 18:19 ` redi at gcc dot gnu.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=20101008154300.mQ_0WsWLvdG6byh-lnt8ZaCmm1bV11E5B_jI97NQkhs@z \
    --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).