public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/54058] New: Injected friend functions are not considered when using contextual type info to take a function address @ 2012-07-20 21:12 andy.m.jost at gmail dot com 2012-07-20 21:51 ` [Bug c++/54058] " redi at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: andy.m.jost at gmail dot com @ 2012-07-20 21:12 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54058 Bug #: 54058 Summary: Injected friend functions are not considered when using contextual type info to take a function address Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: andy.m.jost@gmail.com Created attachment 27851 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27851 Compiler output When attempting to take a function address where contextual type info is needed, injected friend functions are not properly considered. Here is the source file: template<typename Derived> struct Injector { friend Derived const f(Derived const &) { return Derived(); } }; struct A : Injector<A> {}; struct B : Injector<B> {}; int main() { A const (*fp)(A const &) = &f; (void)fp; } The error given is particularly confusing: g++ reports no matching function, but then proceeds to give a list of candidates that includes an exact match! test.cpp: In function ‘int main()’: test.cpp:11:31: error: no matches converting function ‘f’ to type ‘const struct A (*)(const struct A&)’ test.cpp:3:24: error: candidates are: const A f(const A&) test.cpp:3:24: error: const B f(const B&) The full output of "g++ -v -save-temps -Wall -Wextra test.cpp" is attached. Found with g++ 4.5.2. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/54058] Injected friend functions are not considered when using contextual type info to take a function address 2012-07-20 21:12 [Bug c++/54058] New: Injected friend functions are not considered when using contextual type info to take a function address andy.m.jost at gmail dot com @ 2012-07-20 21:51 ` redi at gcc dot gnu.org 2012-07-21 21:45 ` andy.m.jost at gmail dot com 2012-07-21 21:48 ` andy.m.jost at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: redi at gcc dot gnu.org @ 2012-07-20 21:51 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54058 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-20 21:51:30 UTC --- I think G++ is correct. The injected functions can only be found by ADL and ADL only applies to function calls, not when taking the address of a function. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/54058] Injected friend functions are not considered when using contextual type info to take a function address 2012-07-20 21:12 [Bug c++/54058] New: Injected friend functions are not considered when using contextual type info to take a function address andy.m.jost at gmail dot com 2012-07-20 21:51 ` [Bug c++/54058] " redi at gcc dot gnu.org @ 2012-07-21 21:45 ` andy.m.jost at gmail dot com 2012-07-21 21:48 ` andy.m.jost at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: andy.m.jost at gmail dot com @ 2012-07-21 21:45 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54058 --- Comment #2 from Andy Jost <andy.m.jost at gmail dot com> 2012-07-21 21:45:30 UTC --- I think you're right. Section 14.6.5.2 of the 2nd ed. (2003-10-15) has a footnote in section 14.6.5.2. It reads: 131) Friend declarations do not introduce new names into any scope, either when the template is declared of when it is instantiated. Perhaps I just need to provide forward declarations for the friend functions. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/54058] Injected friend functions are not considered when using contextual type info to take a function address 2012-07-20 21:12 [Bug c++/54058] New: Injected friend functions are not considered when using contextual type info to take a function address andy.m.jost at gmail dot com 2012-07-20 21:51 ` [Bug c++/54058] " redi at gcc dot gnu.org 2012-07-21 21:45 ` andy.m.jost at gmail dot com @ 2012-07-21 21:48 ` andy.m.jost at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: andy.m.jost at gmail dot com @ 2012-07-21 21:48 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54058 Andy Jost <andy.m.jost at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #3 from Andy Jost <andy.m.jost at gmail dot com> 2012-07-21 21:48:02 UTC --- Not a bug. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-21 21:48 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-07-20 21:12 [Bug c++/54058] New: Injected friend functions are not considered when using contextual type info to take a function address andy.m.jost at gmail dot com 2012-07-20 21:51 ` [Bug c++/54058] " redi at gcc dot gnu.org 2012-07-21 21:45 ` andy.m.jost at gmail dot com 2012-07-21 21:48 ` andy.m.jost at gmail dot com
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).