From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5607 invoked by alias); 23 Jan 2002 00:26:04 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5562 invoked by uid 71); 23 Jan 2002 00:26:01 -0000 Resent-Date: 23 Jan 2002 00:26:01 -0000 Resent-Message-ID: <20020123002601.5561.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, kenelson@ece.ucdavis.edu Received:(qmail 4827 invoked by uid 61); 23 Jan 2002 00:20:40 -0000 Message-Id:<20020123002040.4823.qmail@sources.redhat.com> Date: Tue, 22 Jan 2002 16:26:00 -0000 From: kenelson@ece.ucdavis.edu Reply-To: kenelson@ece.ucdavis.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/5458: fails to cast to correct pointer type with overloading with templates X-SW-Source: 2002-01/txt/msg00809.txt.bz2 List-Id: >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 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(&foo) only works if there is no complex 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()' >How-To-Repeat: #include template std::complex foo(std::complex) {} void foo(int) {} float foo(float) {} template void ptr_fun(T_result (*f)(T_arg)) {} main() { ptr_fun(foo); } >Fix: >Release-Note: >Audit-Trail: >Unformatted: