Bug 28250 - [4.2 regression] ICE with invalid catch
Summary: [4.2 regression] ICE with invalid catch
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-07-04 16:42 UTC by Volker Reichelt
Modified: 2006-08-01 23:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-07-04 16:42:28 UTC
The following invalid code snippet causes an ICE on mainline:

=================================
template<int> void foo()
{
  try {}
  catch (int(0)) {}
}
=================================

  bug.cc: In function 'void foo()':
  bug.cc:4: error: expected `)' before numeric constant
  bug.cc:4: internal compiler error: tree check: expected tree that contains 'decl common' structure, have 'error_mark'  in pushdecl_maybe_friend, at cp/name-lookup.c:574
  Please submit a full bug report, [etc.]

Will post a patch soon.
Comment 1 patchapp@dberlin.org 2006-07-04 17:00:23 UTC
Subject: Bug number PR c++/28250

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00112.html
Comment 2 patchapp@dberlin.org 2006-07-14 20:25:18 UTC
Subject: Bug number PR c++/28250

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00646.html
Comment 3 Volker Reichelt 2006-07-17 04:42:34 UTC
Subject: Bug 28250

Author: reichelt
Date: Mon Jul 17 04:42:24 2006
New Revision: 115516

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115516
Log:
	PR c++/28250
	* name-lookup.c (pushdecl_maybe_friend): Return early on
	error_mark_node.
	* except.c (expand_start_catch_block): Use error_mark_node instead
	of NULL_TREE for invalid decls.
	* parser.c (cp_parser_exception_declaration): Return error_mark_node
	on invalid catch parameter. Simplify.

	* g++.dg/eh/catch1.C: New test.
	* g++.dg/eh/catch2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/eh/catch1.C
    trunk/gcc/testsuite/g++.dg/eh/catch2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/except.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Volker Reichelt 2006-07-17 04:43:58 UTC
Fixed on mainline.
Comment 5 patchapp@dberlin.org 2006-07-20 15:55:21 UTC
Subject: Bug number PR c++/28250

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00860.html
Comment 6 patchapp@dberlin.org 2006-07-20 16:20:16 UTC
Subject: Bug number PR c++/28250

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00862.html
Comment 7 Volker Reichelt 2006-07-21 10:00:08 UTC
Subject: Bug 28250

Author: reichelt
Date: Fri Jul 21 09:59:57 2006
New Revision: 115643

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115643
Log:
	PR c++/28250
	* pt.c (tsubst_expr): Only apply DECL_TEMPLATE_INSTANTIATED to
	valid decls.  Cleanup.

	* g++.dg/eh/catch3.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/eh/catch3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Volker Reichelt 2006-07-21 10:05:53 UTC
Alas there's some fallout from the fix.
The first issue has been fixed (see comment #5 and #7), another problem remains, though (see also comment #6): 

====================
  void foo()
  {
    try { throw; }
    catch () {}
  }
====================

bug.cc: In function 'void foo()':
bug.cc:4: error: expected type-specifier before ')' token
bug.cc:4: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

The sefault happens deep in the middle-end:

  #0  remove_useless_stmts_1 (tp=0x2aaaaaf831f0, data=0x7fffffd8b670)
      at tree-iterator.h:93
  #1  0x0000000000546aa4 in remove_useless_stmts_1 (tp=<value optimized out>, 
      data=0x7fffffd8b670) at ../../gcc/gcc/tree-cfg.c:1915
  #2  0x0000000000546b55 in remove_useless_stmts_1 (tp=0x2aaaaaf7bf90, 
      data=0x7fffffd8b670) at ../../gcc/gcc/tree-cfg.c:1741
  #3  0x000000000054775d in remove_useless_stmts ()
      at ../../gcc/gcc/tree-cfg.c:1949
  #4  0x00000000008981ae in execute_one_pass (pass=0xc78700)
      at ../../gcc/gcc/passes.c:864
  #5  0x000000000089831c in execute_pass_list (pass=0xc78700)
      at ../../gcc/gcc/passes.c:911
  #6  0x000000000055f359 in tree_lowering_passes (fn=<value optimized out>)
      at ../../gcc/gcc/tree-optimize.c:324
  #7  0x00000000008e7a78 in cgraph_lower_function (node=0x2aaaaaf7d790)
      at ../../gcc/gcc/cgraphunit.c:448
  #8  0x00000000008e8697 in cgraph_analyze_function (node=0x2aaaaaf7d790)
      at ../../gcc/gcc/cgraphunit.c:919
Comment 9 patchapp@dberlin.org 2006-07-26 11:30:25 UTC
Subject: Bug number PR c++/28250

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-07/msg01108.html
Comment 10 Volker Reichelt 2006-08-01 23:45:25 UTC
Subject: Bug 28250

Author: reichelt
Date: Tue Aug  1 23:45:11 2006
New Revision: 115866

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115866
Log:
	PR c++/28250
	PR c++/28257
	PR c++/28259
	PR c++/28267
	* toplev.c (compile_file): Return early on errorcount or sorrycount.
	* cgraphunit.c (cgraph_finalize_compilation_unit): Likewise.
	(cgraph_optimize): Likewise.

	PR c++/28250
	* g++.dg/eh/catch4.C: New test.

	PR c++/28257
	* g++.dg/other/qual1.C: New test.

	PR c++/28259
	* g++.dg/inherit/error2.C: New test.

	PR c++/28267
	* g++.dg/other/new1.C: New test.

	* g++.dg/warn/pr23075.C: Remove obsolete test.
	* g++.old-deja/g++.brendan/crash52.C: Remove dg-warning marker.
	* g++.old-deja/g++.jason/report.C: Remove dg-warning marker.

Added:
    trunk/gcc/testsuite/g++.dg/eh/catch4.C
    trunk/gcc/testsuite/g++.dg/inherit/error2.C
    trunk/gcc/testsuite/g++.dg/other/new1.C
    trunk/gcc/testsuite/g++.dg/other/qual1.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraphunit.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/warn/pr23075.C
    trunk/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C
    trunk/gcc/testsuite/g++.old-deja/g++.jason/report.C
    trunk/gcc/toplev.c

Comment 11 Volker Reichelt 2006-08-01 23:47:56 UTC
Fixed on mainline.
Comment 12 Volker Reichelt 2006-08-03 11:34:09 UTC
Subject: Bug 28250

Author: reichelt
Date: Thu Aug  3 11:33:49 2006
New Revision: 115900

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115900
Log:
	PR c++/28257
	PR c++/28259
	PR c++/28267
	* toplev.c (compile_file): Return early on errorcount or sorrycount.
	* cgraphunit.c (cgraph_finalize_compilation_unit): Likewise.
	(cgraph_optimize): Likewise.

	PR c++/28250
	* g++.dg/eh/catch4.C: New test.

	PR c++/28257
	* g++.dg/other/qual1.C: New test.

	PR c++/28259
	* g++.dg/inherit/error2.C: New test.

	PR c++/28267
	* g++.dg/other/new1.C: New test.

	* g++.dg/warn/pr23075.C: Remove obsolete test.
	* g++.old-deja/g++.brendan/crash52.C: Remove dg-warning marker.
	* g++.old-deja/g++.jason/report.C: Remove dg-warning marker.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/eh/catch4.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/inherit/error2.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/new1.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/qual1.C
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/cgraphunit.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/warn/pr23075.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C
    branches/gcc-4_1-branch/gcc/testsuite/g++.old-deja/g++.jason/report.C
    branches/gcc-4_1-branch/gcc/toplev.c

Comment 13 Volker Reichelt 2006-08-03 11:36:15 UTC
Subject: Bug 28250

Author: reichelt
Date: Thu Aug  3 11:35:52 2006
New Revision: 115901

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115901
Log:
	PR c++/28257
	PR c++/28259
	PR c++/28267
	* toplev.c (compile_file): Return early on errorcount or sorrycount.
	* cgraphunit.c (cgraph_finalize_compilation_unit): Likewise.
	(cgraph_optimize): Likewise.

	PR c++/28250
	* g++.dg/eh/catch4.C: New test.

	PR c++/28257
	* g++.dg/other/qual1.C: New test.

	PR c++/28259
	* g++.dg/inherit/error2.C: New test.

	PR c++/28267
	* g++.dg/other/new1.C: New test.

	* g++.dg/warn/pr23075.C: Remove obsolete test.
	* g++.old-deja/g++.brendan/crash52.C: Remove dg-warning marker.
	* g++.old-deja/g++.jason/report.C: Remove dg-warning marker.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/eh/catch4.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/inherit/error2.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/new1.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/qual1.C
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/cgraphunit.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/gcc/testsuite/g++.dg/warn/pr23075.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.old-deja/g++.brendan/crash52.C
    branches/gcc-4_0-branch/gcc/testsuite/g++.old-deja/g++.jason/report.C
    branches/gcc-4_0-branch/gcc/toplev.c