public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jag-gnu at jag dot dreamhost.com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/32204] friend from global namespace in template class ignored Date: Mon, 17 Jan 2011 06:48:00 -0000 [thread overview] Message-ID: <bug-32204-4-zcR42qpyfI@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-32204-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32204 jag-gnu at jag dot dreamhost.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jag-gnu at jag dot | |dreamhost.com --- Comment #2 from jag-gnu at jag dot dreamhost.com 2011-01-17 05:37:59 UTC --- Output of running a recent g++ on the code in comment 0 with cases 2 and 3 commented out: bug.cpp: In function ‘void f(A::B<int>&)’: bug.cpp:7: error: ‘int A::B<int>::z’ is private bug.cpp:10: error: within this context bug.cpp: In function ‘int main()’: bug.cpp:14: error: call of overloaded ‘f(A::B<int>&)’ is ambiguous bug.cpp:10: note: candidates are: void f(A::B<int>&) bug.cpp:6: note: void A::f(A::B<int>&) Which clearly shows the compiler thinks there is an A::f, even though case 3 says there isn't. I suspect the code below has the same problem: //namespace M { // 1 template <class T> T* makeT() { return new T; } //} namespace N { class Foo { template <class T> friend T* /*M*/::makeT(); //friend Foo* ::makeT<>(); // 2 Foo() {} }; } int main(void) { /*M*/::makeT<N::Foo>(); } bug.cpp: In function ‘T* makeT() [with T = N::Foo]’: bug.cpp:14: instantiated from here bug.cpp:9: error: ‘N::Foo::Foo()’ is private bug.cpp:2: error: within this context Either 1) putting makeT in a class or namespace, or 2) specializing makeT on Foo works around the problem.
next parent reply other threads:[~2011-01-17 5:38 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-32204-4@http.gcc.gnu.org/bugzilla/> 2011-01-17 6:48 ` jag-gnu at jag dot dreamhost.com [this message] 2012-03-26 21:24 ` dpiepgrass at mentoreng dot com 2012-03-26 21:32 ` dpiepgrass at mentoreng dot com 2012-03-26 23:52 ` redi at gcc dot gnu.org 2012-03-27 0:44 ` redi at gcc dot gnu.org 2012-10-27 8:12 ` scottbaldwin at gmail dot com 2012-10-27 8:52 ` scottbaldwin at gmail dot com 2012-10-27 13:13 ` redi at gcc dot gnu.org 2012-10-27 13:39 ` scottbaldwin at gmail dot com 2007-06-04 12:01 [Bug c++/32204] New: " klaus dot kretschel at dlr dot de 2009-12-08 23:11 ` [Bug c++/32204] " redi 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=bug-32204-4-zcR42qpyfI@http.gcc.gnu.org/bugzilla/ \ --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: linkBe 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).