Bug 36897 - [4.2 Regression] ICE with function pointer template parameter
Summary: [4.2 Regression] ICE with function pointer template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.1
: P2 normal
Target Milestone: 4.3.4
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2008-07-22 11:37 UTC by Dario Saccavino
Modified: 2009-03-31 15:45 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6 4.3.4 4.4.0
Known to fail: 4.0.4 4.1.2 4.3.3 4.2.5
Last reconfirmed: 2008-08-17 00:04:47


Attachments
tentative patch (367 bytes, patch)
2009-02-03 10:38 UTC, Paolo Bonzini
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dario Saccavino 2008-07-22 11:37:15 UTC
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.
Comment 1 Paolo Carlini 2008-07-22 11:48:19 UTC
Te be clear, this is ICE on invalid
Comment 2 Andrew Pinski 2008-08-17 00:04:47 UTC
Confirmed.
Comment 3 Richard Biener 2008-08-22 14:51:40 UTC
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
Comment 4 Paolo Bonzini 2009-02-03 10:38:56 UTC
Created attachment 17231 [details]
tentative patch
Comment 5 Paolo Bonzini 2009-02-03 11:11:10 UTC
caused by r90059 (convert_nontype_argument rewrite).  Giovanni, do you have time to see if the patch I made makes sense?
Comment 6 Paolo Bonzini 2009-02-03 15:56:19 UTC
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

Comment 7 Paolo Bonzini 2009-02-03 16:20:34 UTC
fixed on 4.3/4.4, still needs backporting to 4.2
Comment 8 Paolo Carlini 2009-02-03 16:22:12 UTC
Did you really commit it to mainline? I don't see it.
Comment 9 Paolo Bonzini 2009-02-03 16:26:51 UTC
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. :-)
Comment 10 Paolo Bonzini 2009-02-03 16:26:51 UTC
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

Comment 11 Joseph S. Myers 2009-03-31 15:45:38 UTC
Closing 4.2 branch, fixed for 4.3.4 and 4.4.