Trying to compile the following program: typedef void (*fptr)(); fptr zeroptr = 0; template<typename T, fptr F> struct foo { }; template<typename T> struct foo<T,zeroptr> { }; void f() { } foo<int,&f> m_foo; I get the message: test.cpp:6: internal compiler error: in unify, at cp/pt.c:13401 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions.
Te be clear, this is ICE on invalid
Confirmed.
For the curious, G++ 3.4.6 says t.ii:4: error: `zeroptr' is not a valid template argument t.ii:4: error: it must be the address of a function with external linkage
Created attachment 17231 [details] tentative patch
caused by r90059 (convert_nontype_argument rewrite). Giovanni, do you have time to see if the patch I made makes sense?
Subject: Bug 36897 Author: bonzini Date: Tue Feb 3 15:56:05 2009 New Revision: 143896 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143896 Log: gcc/cp: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * pt.c (convert_nontype_argument_function): Expect expr to be an ADDR_EXPR. PR c++/37314 * typeck.c (merge_types): Call resolve_typename_type if only one type is a typename. gcc/testsuite: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * g++.dg/template/func2.C: New test. PR c++/37314 * g++.dg/template/typename15.C: New. * g++.dg/template/typename16.C: New. Added: branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/func2.C branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename15.C branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename16.C Modified: branches/gcc-4_3-branch/gcc/cp/ChangeLog branches/gcc-4_3-branch/gcc/cp/pt.c branches/gcc-4_3-branch/gcc/cp/typeck.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
fixed on 4.3/4.4, still needs backporting to 4.2
Did you really commit it to mainline? I don't see it.
Subject: Re: [4.2 Regression] ICE with function pointer template parameter > Did you really commit it to mainline? I don't see it. I was doing it. :-)
Subject: Bug 36897 Author: bonzini Date: Tue Feb 3 16:26:28 2009 New Revision: 143898 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143898 Log: gcc/cp: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * pt.c (convert_nontype_argument_function): Expect expr to be an ADDR_EXPR. PR c++/37314 * typeck.c (merge_types): Call resolve_typename_type if only one type is a typename. gcc/testsuite: 2009-02-03 Paolo Bonzini <bonzini@gnu.org> PR c++/36897 * g++.dg/template/func2.C: New test. PR c++/37314 * g++.dg/template/typename15.C: New. * g++.dg/template/typename16.C: New. Added: trunk/gcc/testsuite/g++.dg/template/func2.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/func2.C trunk/gcc/testsuite/g++.dg/template/typename15.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename15.C trunk/gcc/testsuite/g++.dg/template/typename16.C - copied unchanged from r143896, branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typename16.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Closing 4.2 branch, fixed for 4.3.4 and 4.4.