Overload resolution causes instantiation of 'T Foo<void> (int)', when trying 'void Baz (void (*)(int), int)'. that is not selected by overload resolution, but we go ahead an instantiate the body of Foo anyway (which fails).
Created attachment 4745 [details] testcase
I believe we're calling mark_used too early during overload resolution.
Confirmed. This is a regression introduced between 2.95 and 3.0. W.
Subject: Bug 12266 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-09-17 23:42:56 Modified files: gcc/cp : ChangeLog call.c class.c cp-tree.h gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/overload: template1.C Log message: PR c++/12266 * cp-tree.h (tsubst_flags_t): Add tf_conv. * class.c (standard_conversion): Pass tf_conv to instantiate_type. (resolve_address_of_overloaded_function): Do not call mark_used when just checking conversions. PR c++/12266 * g++.dg/overload/template1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3684&r2=1.3685 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.433&r2=1.434 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.572&r2=1.573 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.917&r2=1.918 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3060&r2=1.3061 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/template1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed in GCC 3.3.2, GCC 3.4.