User account creation filtered due to spam.

Bug 13268 - ICE on illegal code: bool foo(const operator&);
Summary: ICE on illegal code: bool foo(const operator&);
Status: RESOLVED DUPLICATE of bug 19063
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 minor
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2003-12-02 06:29 UTC by Florian Weimer
Modified: 2005-08-05 21:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-09-01 13:47:17


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2003-12-02 06:29:10 UTC
This apparently illegal code snippet triggers an ICE:

bool foo(const operator&);

/tmp/t.cc:1: error: declaration of `operator&' as non-function
/tmp/t.cc:1: internal compiler error: Segmentation fault
Comment 1 Wolfgang Bangerth 2003-12-02 14:31:01 UTC
Confirmed, the same behavior since 2.95 at least. Since this
is only ice-after-error, it gets low priority.

W.
Comment 2 Andrew Pinski 2003-12-02 15:51:16 UTC
Program received signal EXC_BAD_ACCESS, Could not access memory.
grokdeclarator (declarator=0x4187cec0, declspecs=0x4187b0f0, decl_context=NORMAL, 
initialized=0, attrlist=0xbffff964) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/decl.c:8608
8608          if (VOID_TYPE_P (type))
(gdb) bt
#0  grokdeclarator (declarator=0x4187cec0, declspecs=0x4187b0f0, decl_context=NORMAL, 
initialized=0, attrlist=0xbffff964) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/decl.c:8608
#1  0x00019c8c in start_decl (declarator=0x0, declspecs=0x0, initialized=0, attributes=0x0, 
prefix_attributes=0x453c94) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/
decl.c:3651
#2  0x00019c8c in start_decl (declarator=0x0, declspecs=0x0, initialized=0, attributes=0x0, 
prefix_attributes=0x453c94) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/
decl.c:3651
#3  0x0005b738 in cp_parser_init_declarator (parser=0x0, decl_specifiers=0x0, 
prefix_attributes=0x4187cec0, function_definition_allowed_p=4537492, member_p=1099411696, 
declares_class_or_enum=0, function_definition_p=0x453c94) at /Volumes/UFS_Partition/pinskia/
src/fsf/gcc-clean/src/gcc/cp/parser.c:9579
#4  0x0005ba84 in cp_parser_simple_declaration (parser=0x0, 
function_definition_allowed_p=false) at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/
gcc/cp/parser.c:6246
#5  0x0005bc70 in cp_parser_block_declaration (parser=0x4187acb0, statement_p=false) at /
Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:6162
#6  0x0005c8f0 in cp_parser_declaration (parser=0x4187acb0) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:6082
#7  0x0005cbf8 in cp_parser_declaration_seq_opt (parser=0x4187acb0) at /Volumes/
UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/cp/parser.c:5991
#8  0x0005cdc0 in c_parse_file () at /Volumes/UFS_Partition/pinskia/src/fsf/gcc-clean/src/gcc/
cp/parser.c:2195
#9  0x000bbec8 in c_common_parse_file (set_yydebug=1090264352) at /Volumes/UFS_Partition/
pinskia/src/fsf/gcc-clean/src/gcc/c-opts.c:1227
p #10 0x0031e7ac in toplev_main (argc=4588092, argv=0x1) at /Volumes/UFS_Partition/pinskia/
src/fsf/gcc-clean/src/gcc/toplev.c:1808
#11 0x00001d10 in _start (argc=14, argv=0xbffffd70, envp=0xbffffdac) at /SourceCache/Csu/
Csu-46/crt.c:267
#12 0x00001b84 in start ()
(gdb) p type
$1 = 0x40fb68c0
(gdb) p type
$2 = 0x40fb68c0
(gdb) p debug_tree(type)
 <boolean_type 0x40fb68c0 bool unsigned SI
    size <integer_cst 0x40fb4300 type <integer_type 0x40fc1af0 bit_size_type> constant 32>
    unit size <integer_cst 0x40fb43a8 type <integer_type 0x40fc1a80 long unsigned int> constant 
4>
    align 32 symtab 0 alias set -1 precision 1 min <integer_cst 0x40fb4588 0> max <integer_cst 
0x40fb45d0 1>>
$3 = void
(gdb) l
8603
8604          if (attrs)
8605            cplus_decl_attributes (&decl, attrs, 0);
8606
8607          type = TREE_TYPE (decl);
8608          if (VOID_TYPE_P (type))
8609            {
8610              if (same_type_p (type, void_type_node)
8611                  && !DECL_NAME (decl) && !result && !chain && !ellipsis)
8612                /* this is a parmlist of `(void)', which is ok.  */
Comment 3 Andrew Pinski 2003-12-24 06:29:05 UTC
I have a fix for at least the non checking case.
Comment 4 Andrew Pinski 2003-12-24 17:43:00 UTC
My patch fixes it, will submit it soon.
Comment 5 Andrew Pinski 2003-12-24 18:03:07 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02051.html>.
Comment 6 CVS Commits 2003-12-25 16:28:53 UTC
Subject: Bug 13268

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2003-12-25 16:28:51

Modified files:
	gcc/cp         : pt.c class.c ChangeLog 

Log message:
	PR c++/13268, c++/13339
	* class.c (add_method): Return early when method is error_mark_node.
	* pt.c (tsubst_friend_function): Return early when new_friend is
	error_mark_node.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.807&r2=1.808
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.590&r2=1.591
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3834&r2=1.3835

Comment 7 Andrew Pinski 2003-12-25 16:29:56 UTC
Fixed for 3.4.
Comment 8 Volker Reichelt 2003-12-30 20:34:24 UTC
I still get a segfault on i686-pc-linux-gnu with gcc 3.4.0 20031229
(checking enabled):

PR13268.cc:1: error: declaration of `operator&' as non-function
PR13268.cc:1: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]
Comment 9 Andrew Pinski 2003-12-30 20:42:55 UTC
The last part of the patch is needed:
Index: decl.c
============================================================
=======
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1170
diff -u -p -r1.1170 decl.c
--- decl.c      30 Dec 2003 12:18:26 -0000      1.1170
+++ decl.c      30 Dec 2003 20:41:50 -0000
@@ -8623,7 +8623,7 @@ grokparms (tree first_parm)
       split_specs_attrs (TREE_PURPOSE (decl), &specs, &attrs);
       decl = grokdeclarator (TREE_VALUE (decl), specs,
                             PARM, init != NULL_TREE, &attrs);
-      if (! decl || TREE_TYPE (decl) == error_mark_node)
+      if (! decl || !TREE_TYPE (decl) || TREE_TYPE (decl) == error_mark_node )
         continue;
 
       if (attrs)
Comment 10 Andrew Pinski 2004-04-23 19:40:35 UTC
Not working on it anymore.
Comment 11 Andrew Pinski 2004-09-27 04:01:37 UTC
As I said I am no longer working on this so removing the patch keyword.
Comment 12 CVS Commits 2004-12-22 03:35:10 UTC
Subject: Bug 13268

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-12-22 03:34:59

Modified files:
	gcc/cp         : ChangeLog call.c decl.c parser.c tree.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: packed8.C 
	gcc/testsuite/g++.dg/template: crash31.C crash30.C 

Log message:
	PR c++/18378
	* call.c (convert_like_real): Do not permit the use of a copy
	constructor to copy a packed field.
	
	PR c++/17413
	* decl.c (grokdeclarator): Return error_mark_node, not
	void_type_node, to indicate errors.
	* parser.c (cp_parser_template_parameter_list): Robustify.
	(cp_parser_template_parameter): Likewise.
	
	PR c++/19034
	* tree.c (cp_tree_equal): Handle OVERLOAD.
	
	PR c++/18378
	* g++.dg/ext/packed8.C: New test.
	
	PR c++/13268
	* g++.dg/template/crash31.C: New test.
	
	PR c++/19034
	* g++.dg/template/crash30.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4550&r2=1.4551
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.523&r2=1.524
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1345&r2=1.1346
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.296&r2=1.297
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.420&r2=1.421
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/packed8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash31.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash30.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4796&r2=1.4797

Comment 13 Volker Reichelt 2004-12-23 16:21:15 UTC
Fixed in mainline (which will become 4.0.0).
Comment 14 Mark Mitchell 2005-08-05 21:04:06 UTC
Reopending to mark as duplicate of PR 19063.
Comment 15 Mark Mitchell 2005-08-05 21:04:19 UTC

*** This bug has been marked as a duplicate of 19063 ***