Bug 15044

Summary: [3.4/4.0 Regression] ICE on syntax error, template header.
Product: gcc Reporter: duz
Component: c++Assignee: Mark Mitchell <mark>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, giles, switch
Priority: P2 Keywords: ice-on-invalid-code
Version: 3.4.0   
Target Milestone: 3.4.1   
Host: Target:
Build: Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0 Last reconfirmed: 2004-04-21 14:02:15

Description duz 2004-04-21 13:54:28 UTC
ICE on syntax error as follows:

template class <num_t> class a { num_t n; }

Using gcc-3.4.0 bootstapped on Linux for i386,

cd /home/duz/cc/
gcc-3.4 -v -O -S tst.cc
Reading specs from /opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: /pub/unpacked/gcc-3.4.0/configure --prefix=/opt/gnu/gcc-3.4.0
--enable-languages=c,c++ --disable-shared --disable-nls --disable-multilib
--program-suffix=-3.4
Thread model: posix
gcc version 3.4.0
 /opt/gnu/gcc-3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -quiet -v
-D_GNU_SOURCE tst.cc -quiet -dumpbase tst.cc -mtune=pentiumpro -auxbase tst -O
-version -o tst.s
ignoring nonexistent directory
"/opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
 /opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /usr/local/include
 /opt/gnu/gcc-3.4.0/include
 /opt/gnu/gcc-3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
	compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64471
tst.cc:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Compilation exited abnormally with code 1 at Wed Apr 21 15:54:06
Comment 1 Andrew Pinski 2004-04-21 14:02:13 UTC
Confirmed.
Here is the backtrace for the mainline:
1891          if (TYPE_P (type))
(gdb) bt
#0  cp_parser_check_for_invalid_template_id (parser=0x40129880, type=0x0) at /home/gates/
pinskia/src/gnu/gcc/src/gcc/cp/parser.c:1891
#1  0x080ea524 in cp_parser_type_specifier (parser=0x40129880, flags=Variable "flags" is not 
available.
) at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:12099
#2  0x080eb4ce in cp_parser_decl_specifier_seq (parser=0x40129880, 
flags=CP_PARSER_FLAGS_OPTIONAL, attributes=0xbffebbb4,
    declares_class_or_enum=0xbffebbb8) at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:
6796
#3  0x080f2b5c in cp_parser_explicit_instantiation (parser=0x40129880) at /home/gates/pinskia/src/
gnu/gcc/src/gcc/cp/parser.c:8586
#4  0x080f2e47 in cp_parser_declaration (parser=0x40129880) at /home/gates/pinskia/src/gnu/gcc/
src/gcc/cp/parser.c:6385
#5  0x080f3020 in cp_parser_declaration_seq_opt (parser=0x40127cc8) at /home/gates/pinskia/src/
gnu/gcc/src/gcc/cp/parser.c:6300
#6  0x080f320e in c_parse_file () at /home/gates/pinskia/src/gnu/gcc/src/gcc/cp/parser.c:2393
#7  0x0818194b in c_common_parse_file (set_yydebug=0) at /home/gates/pinskia/src/gnu/gcc/src/
gcc/c-opts.c:1238
#8  0x083bf491 in toplev_main (argc=1074953416, argv=0x84be8a0) at /home/gates/pinskia/src/
gnu/gcc/src/gcc/toplev.c:1595
#9  0x0818556e in main (argc=1074953416, argv=0x40127cc8) at /home/gates/pinskia/src/gnu/
gcc/src/gcc/main.c:35
Comment 2 Mark Mitchell 2004-05-23 23:01:18 UTC
Working on a fix.
Comment 3 GCC Commits 2004-05-24 02:23:49 UTC
Subject: Bug 15044

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-05-24 02:22:19

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/ext: attrib14.C 
	gcc/testsuite/g++.dg/template: error12.C ptrmem9.C 

Log message:
	PR c++/15044
	* parser.c (cp_parser_class_head): Robustify.
	
	PR c++/15317
	* parser.c (cp_parser_decl_specifier_seq): Correct error in
	comment.
	(cp_parser_constructor_declarator_p): Treat attributes
	as decl-specifiers.
	
	PR c++/15329
	* typeck.c (build_unary_op): Do not attempt to resolve casts to
	base classes in templates.
	
	PR c++/15044
	* g++.dg/template/error12.C: New test.
	
	PR c++/15317
	* g++.dg/ext/attrib14.C: New test.
	
	PR c++/15329
	* g++.dg/template/ptrmem9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.182&r2=1.3389.2.183
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.105&r2=1.3892.2.106
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.27&r2=1.157.2.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.15&r2=1.519.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib14.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.2.16.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error12.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem9.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 4 GCC Commits 2004-05-24 02:29:48 UTC
Subject: Bug 15044

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-05-24 02:29:35

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c typeck.c 
Added files:
	gcc/testsuite/g++.dg/ext: attrib15.C 
	gcc/testsuite/g++.dg/template: error12.C ptrmem9.C 

Log message:
	PR c++/15044
	* parser.c (cp_parser_class_head): Robustify.
	
	PR c++/15317
	* parser.c (cp_parser_decl_specifier_seq): Correct error in
	comment.
	(cp_parser_constructor_declarator_p): Treat attributes
	as decl-specifiers.
	
	PR c++/15329
	* typeck.c (build_unary_op): Do not attempt to resolve casts to
	base classes in templates.
	
	PR c++/15044
	* g++.dg/template/error12.C: New test.
	
	PR c++/15317
	* g++.dg/ext/attrib15.C: New test.
	
	PR c++/15329
	* g++.dg/template/ptrmem9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3777&r2=1.3778
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4056&r2=1.4057
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.194&r2=1.195
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.543&r2=1.544
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib15.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error12.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem9.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 5 GCC Commits 2004-05-24 02:30:41 UTC
Subject: Bug 15044

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-05-24 02:30:28

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: attrib15.C 

Log message:
	PR c++/15044
	* parser.c (cp_parser_class_head): Robustify.
	
	PR c++/15317
	* parser.c (cp_parser_decl_specifier_seq): Correct error in
	comment.
	(cp_parser_constructor_declarator_p): Treat attributes
	as decl-specifiers.
	
	PR c++/15329
	* typeck.c (build_unary_op): Do not attempt to resolve casts to
	base classes in templates.
	
	PR c++/15044
	* g++.dg/template/error12.C: New test.
	
	PR c++/15317
	* g++.dg/ext/attrib15.C: New test.
	
	PR c++/15329
	* g++.dg/template/ptrmem9.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.183&r2=1.3389.2.184
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib15.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 6 Mark Mitchell 2004-05-24 02:34:20 UTC
Fixed in GCC 3.4.1.
Comment 7 Volker Reichelt 2004-06-22 15:20:13 UTC
*** Bug 16133 has been marked as a duplicate of this bug. ***
Comment 8 Wolfgang Bangerth 2004-06-28 13:43:28 UTC
*** Bug 16244 has been marked as a duplicate of this bug. ***