User account creation filtered due to spam.

Bug 12146 - [3.3/3.4 Regression] ICE in lookup_template_function at cp/pt.c:4005
Summary: [3.3/3.4 Regression] ICE in lookup_template_function at cp/pt.c:4005
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2003-09-02 23:32 UTC by Wesley J. Landaker
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host: i586-mandrake-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-09-03 11:42:04


Attachments
This is the preprocessed source that makes it ICE. (100.13 KB, text/plain)
2003-09-02 23:34 UTC, Wesley J. Landaker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wesley J. Landaker 2003-09-02 23:32:54 UTC
Compiling some code with some partially specialized templates causes and ICE. 
The code itself may be incorrect in some way, but it shouldn't cause an ICE. 
 
Here is the appropriate info. I will attach the preprocessed source in just a 
moment (there doesn't seem to be a way to do it from this bugzilla screen). 
 
$ g++ -o test Convert.ii -v 
Reading specs from /usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/specs 
Configured with: ../configure --prefix=/usr --libdir=/usr/lib 
--with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info 
--enable-shared --enable-threads=posix --disable-checking --enable-long-long 
--enable-__cxa_atexit --enable-languages=c,c++,ada,f77,objc,java,pascal 
--host=i586-mandrake-linux-gnu --with-system-zlib 
Thread model: posix 
gcc version 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk) 
 /usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.3.1/cc1plus -fpreprocessed 
Convert.ii -quiet -dumpbase Convert.ii -auxbase Convert -version -o 
/tmp/ccBkAw2p.s 
GNU C++ version 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk) (i586-mandrake-linux-gnu) 
        compiled by GNU C version 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk). 
GGC heuristics: --param ggc-min-expand=55 --param ggc-min-heapsize=48162 
Convert.cpp:14: internal compiler error: in lookup_template_function, at 
cp/pt.c:4005 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:https://qa.mandrakesoft.com/> for instructions.
Comment 1 Wesley J. Landaker 2003-09-02 23:34:12 UTC
Created attachment 4689 [details]
This is the preprocessed source that makes it ICE.

Here is the preprocessed source that causes the problem.
Comment 2 Gwenole Beauchesne 2003-09-03 07:30:38 UTC
Subject: Re:  ICE in lookup_template_function at cp/pt.c:4005

On Wed, 2 Sep 2003, wjl at icecavern dot net wrote:

> Created an attachment (id=4689)
>  --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=4689&action=view)
> This is the preprocessed source that makes it ICE.

Here is a simplified testcase:

// { dg-do compile }

// PR c++/12146: Incorrect template specialization of non-template function.

struct A { };
struct B { };

A f(const B & b) {
	return A();
}

template<>
B f(const A & a) { // { dg-error "not match" }
	return B();
}
Comment 3 Gwenole Beauchesne 2003-09-03 07:58:07 UTC
This is a regression from 3.2.3 available on 3.3-branch. As tested with:
GNU C++ version 3.3.2 20030903 (prerelease) (i686-pc-linux-gnu)

[gb@hp6 gcc]$ ./cc1plus ~/vrac/t.cpp
 A f(const B&) A f(const B&)
/home/gb/vrac/t.cpp: At global scope:
/home/gb/vrac/t.cpp:13: internal compiler error: in lookup_template_function,
   at cp/pt.c:4005
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 4 Andrew Pinski 2003-09-03 11:42:04 UTC
From Phil's regression hunter: Search converges between 2002-07-28-trunk (#83) and 
2002-08-04-trunk (#84). 

Most likely caused by (just by looking into gcc-patches for changes that might have 
caused this):
2002-07-31  Mark Mitchell  <mark@codesourcery.com>

        * call.c (build_field_call): Do not look up the field by name.
        (build_method_call): Simplify.
        (struct z_candidate): Add access_path and conversion_path.  Remove
        basetype_path.
        (convert_class_to_reference): Adjust use of
        add_function_candidate.
        (add_candidate): Add conversion_path argument.
        (add_function_candidate): Use it.
        (add_conv_dndidate): Likewise. 
        [....]
Comment 5 Wesley J. Landaker 2003-09-03 16:16:51 UTC
BTW, the code is actually bad; there is a stray "template <>" in this snippet 
(from Convert.ii -- line no ~17495) 
 
 template <> 
  Value convert_std__string(const std::string &) { 
    return Value(rb_str_new(s.data(), s.length())); 
  } 
 
This doesn't forgive the ICE, but hopefully will make it easier to track down. 
=) 
Comment 6 CVS Commits 2003-09-05 18:04:32 UTC
Subject: Bug 12146

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2003-09-05 18:04:22

Modified files:
	gcc/cp         : ChangeLog call.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/expr: static_cast4.C 
	gcc/testsuite/g++.dg/template: crash9.C 

Log message:
	PR c++/12163
	* call.c (perform_direct_initialization): Correct logic for
	direct-initialization of a class type.
	
	PR c++/12146
	* pt.c (lookup_template_function): Robustify.
	
	PR c++/12163
	* g++.dg/expr/static_cast4.C: New test.
	
	PR c++/12146
	* g++.dg/template/crash9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3648&r2=1.3649
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.430&r2=1.431
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.774&r2=1.775
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3026&r2=1.3027
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/expr/static_cast4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 7 CVS Commits 2003-09-05 18:31:22 UTC
Subject: Bug 12146

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	mmitchel@gcc.gnu.org	2003-09-05 18:31:19

Modified files:
	gcc/cp         : ChangeLog call.c pt.c 
	gcc/testsuite  : ChangeLog 

Log message:
	PR c++/12163
	* call.c (perform_direct_initialization): Correct logic for
	direct-initialization of a class type.
	
	PR c++/12146
	* pt.c (lookup_template_function): Robustify.
	
	PR c++/12163
	* g++.dg/expr/static_cast4.C: New test.
	
	PR c++/12146
	* g++.dg/template/crash9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.198&r2=1.3076.2.199
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.30&r2=1.341.2.31
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.635.2.35&r2=1.635.2.36
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.266&r2=1.2261.2.267

Comment 8 Mark Mitchell 2003-09-05 18:39:05 UTC
Fixed in GCC 3.3.2, GCC 3.4.