public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5458: fails to cast to correct pointer type with overloading with templates
@ 2002-04-25 7:44 nathan
0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-04-25 7:44 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, kenelson, nobody
Synopsis: fails to cast to correct pointer type with overloading with templates
State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Thu Apr 25 07:44:10 2002
State-Changed-Why:
yup
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5458
^ permalink raw reply [flat|nested] 2+ messages in thread
* c++/5458: fails to cast to correct pointer type with overloading with templates
@ 2002-01-22 16:26 kenelson
0 siblings, 0 replies; 2+ messages in thread
From: kenelson @ 2002-01-22 16:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 5458
>Category: c++
>Synopsis: fails to cast to correct pointer type with overloading with templates
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Jan 22 16:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Karl Nelson
>Release: g++ version 3.0.3
>Organization:
>Environment:
All (platform independent)
>Description:
While attempting to use the std function ptr_fun on an overloaded function (sin), I found the compiler would fail if <complex> was included. This traced to an error in the lookups of functions.
Apparently, you can use template specifiers to choose
the overload only when a templated version of the
function has not been encountered. I boiled all of the
headers down to the following example.
ptr_fun<double>(&foo) only works if there is no
complex<T> version declared. I verified this was
valid code on HPUX compilers, but do not have access to
the standard to clarify code is proper completely.
Example program generates incorrect error message.
kenelson:/tmp> g++-3 ptr_fun.cc
ptr_fun.cc: In function `int main()':
ptr_fun.cc:7: no matching function for call to `ptr_fun(<unknown type>)'
>How-To-Repeat:
#include <complex>
template <class T> std::complex<T> foo(std::complex<T>) {}
void foo(int) {}
float foo(float) {}
template <class T_arg, class T_result>
void ptr_fun(T_result (*f)(T_arg)) {}
main() { ptr_fun<float>(foo); }
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-25 14:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-25 7:44 c++/5458: fails to cast to correct pointer type with overloading with templates nathan
-- strict thread matches above, loose matches on Subject: below --
2002-01-22 16:26 kenelson
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).