Bug 11513 - [3.4 Regression] ICE in push_template_decl_real cp/pt.c:2755, template member functions
Summary: [3.4 Regression] ICE in push_template_decl_real cp/pt.c:2755, template member...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P1 critical
Target Milestone: 3.3.1
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2003-07-13 16:24 UTC by David Robinson
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-07-22 14:19:04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Robinson 2003-07-13 16:24:41 UTC
When parsing a member template function of a template, the compiler
crashes on variable definitions of the form 'struct foo b;'.
I think the problem is in the PROCESSING_REAL_TEMPLATE_DECL_P() macro
which gives the wrong result when within member template functions.

See the example below; when parsing struct foo b; the compiler crashes.
This may be caused by the use of PROCESSING_REAL_TEMPLATE_DECL_P() returning
1 in xref_tag() at cp/decl.c: 13297.

template <typename T>
struct bar                      // template_class_depth(bar<T>) = 1
{ 
    struct foo
    {
	int a;
    };

    template <typename U>
    int wom(U c)
    {
 	struct foo b;         // processing_template_decl = 2
    };
};
Comment 1 Andrew Pinski 2003-07-13 18:37:27 UTC
I can confirm this on 2.95.3, 3.0.4, 3.2.3, 3.3.1 (20030707), and the mainline (20030713) 
but it did not ICE with 2.91.66 so this is a regression from that. An old regression but still 
a regression.
Comment 2 Andrew Pinski 2003-07-13 18:46:24 UTC
I had forgot to change the target milestone because it is a regression.
Comment 3 Nathanael C. Nerode 2003-07-14 03:38:19 UTC
>I think the problem is in the PROCESSING_REAL_TEMPLATE_DECL_P() macro
>which gives the wrong result when within member template functions.
There are dozens of bug reports about member template functions.  I wonder how
many of them are linked to the same problem?...
Comment 4 Kriang Lerdsuwanakij 2003-07-18 14:48:43 UTC
That problematic PROCESSING_REAL_TEMPLATE_DECL_P() macro
would be removed in 3.4 by my proposed fix to PR8442.
I am preparing an updated version now.  Not sure about
the 3.3 branch though.
Comment 5 Kriang Lerdsuwanakij 2003-07-19 13:05:06 UTC
Patch for 3.4 is posted:

  http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01960.html

For 3.3, I think we have to fix PROCESSING_REAL_TEMPLATE_DECL_P()
anyway, maybe in 3.3.2.  
Comment 6 Kriang Lerdsuwanakij 2003-07-20 11:01:43 UTC
Patch submitted for 3.3 and mainline:

  http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02009.html
Comment 7 David Robinson 2003-07-23 20:58:35 UTC
Yes, that patch for 3.3 fixes my problem.
Comment 8 Mark Mitchell 2003-07-23 23:41:54 UTC
Kriang --

Your patch http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02009.html is OK for the
branch and the mainline.  Would you please apply it, and move the target for
this PR to 3.4?

Thanks,

-- Mark
Comment 10 Kriang Lerdsuwanakij 2003-07-24 11:39:59 UTC
Move target to 3.4.  Patch committed to 3.3 (to be appeared in 3.3.1).
For 3.4, I'll apply the PROCESSING_REAL_TEMPLATE_DECL_P patch.  The one
for PR8442 still has to wait for approval.
Comment 11 GCC Commits 2003-07-24 11:56:36 UTC
Subject: Bug 11513

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2003-07-24 11:56:33

Modified files:
	gcc/cp         : ChangeLog cp-tree.h 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: crash8.C 

Log message:
	PR c++/11513
	* cp-tree.h (PROCESSING_REAL_TEMPLATE_DECL_P): Use current_scope.
	
	* g++.dg/template/crash8.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3546&r2=1.3547
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.885&r2=1.886
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2914&r2=1.2915
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash8.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 12 Volker Reichelt 2003-07-25 08:38:07 UTC
Fixed for 3.3.1 and mainline.