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 }; };
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.
I had forgot to change the target milestone because it is a regression.
>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?...
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.
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.
Patch submitted for 3.3 and mainline: http://gcc.gnu.org/ml/gcc-patches/2003-07/msg02009.html
Yes, that patch for 3.3 fixes my problem.
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
Subject: Bug 11513 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: lerdsuwa@gcc.gnu.org 2003-07-24 11:29:51 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&only_with_tag=gcc-3_3-branch&r1=1.3076.2.187&r2=1.3076.2.188 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.28&r2=1.776.2.29 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.243&r2=1.2261.2.244 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash8.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
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.
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
Fixed for 3.3.1 and mainline.