Bug 34850 - [4.3 Regression] Recursive BLOCK tree causes compilation to hang during diagnostics
Summary: [4.3 Regression] Recursive BLOCK tree causes compilation to hang during diagn...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.3.0
Assignee: Richard Biener
URL:
Keywords: compile-time-hog, diagnostic
Depends on:
Blocks:
 
Reported: 2008-01-18 14:44 UTC by Richard Biener
Modified: 2008-01-21 09:34 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-01-18 15:09:41


Attachments
reduced testcase (659 bytes, text/plain)
2008-01-18 14:44 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2008-01-18 14:44:01 UTC
Compilation of the attached testcase hangs in 

0x000000000056aedc in cp_print_error_function (context=0x15c5a60, 
    diagnostic=0x7fff955f6c30)
    at /space/rguenther/src/svn/trunk/gcc/cp/error.c:2426
2426                      while (TREE_CODE (ao) == BLOCK && BLOCK_ABSTRACT_ORIGIN (ao))
2427                        ao = BLOCK_ABSTRACT_ORIGIN (ao);

because BLOCK_ABSTRACT_ORIGIN (ao) == ao.

If you build with -O2 -g.  Building without -g fixes the problem
(possibly the BLOCK is thrown away as unused).
Comment 1 Richard Biener 2008-01-18 14:44:29 UTC
Created attachment 14967 [details]
reduced testcase
Comment 2 Richard Biener 2008-01-18 14:53:38 UTC
The recursion is created by set_block_origin_self (), called from

#0  set_block_origin_self (stmt=0x2b4ce448cd80)
    at /space/rguenther/src/svn/trunk/gcc/integrate.c:105
#1  0x000000000098ca87 in set_decl_origin_self (decl=0x2b4ce4479680)
    at /space/rguenther/src/svn/trunk/gcc/integrate.c:154
#2  0x0000000000810f41 in gen_decl_die (decl=0x2b4ce4479680, 
    context_die=0x2b4ce445e0c0)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:13873
#3  0x00000000008129d3 in dwarf2out_decl (decl=0x2b4ce4479680)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:14214
#4  0x00000000008880c7 in rest_of_handle_final ()
    at /space/rguenther/src/svn/trunk/gcc/final.c:4152

while we still (after that), try to emit diagnostics via

#0  0x000000000056ae92 in cp_print_error_function (context=0x15c5a60, 
    diagnostic=0x7fffc70736b0)
    at /space/rguenther/src/svn/trunk/gcc/cp/error.c:2426
#1  0x000000000056a9f4 in cp_diagnostic_starter (context=0x15c5a60, 
    diagnostic=0x7fffc70736b0)
    at /space/rguenther/src/svn/trunk/gcc/cp/error.c:2364
#2  0x00000000007e2168 in diagnostic_report_diagnostic (context=0x15c5a60, 
    diagnostic=0x7fffc70736b0)
    at /space/rguenther/src/svn/trunk/gcc/diagnostic.c:421
#3  0x00000000007e25e4 in warning (opt=0, 
    gmsgid=0x112a8e8 "%Kcall to %qs declared with attribute warning: %s")
    at /space/rguenther/src/svn/trunk/gcc/diagnostic.c:511
#4  0x0000000000866d15 in expand_expr_real_1 (exp=0x2b4ce44e5230, target=0x0, 
    tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0)
    at /space/rguenther/src/svn/trunk/gcc/expr.c:8043
#5  0x000000000085ff13 in expand_expr_real (exp=0x2b4ce44e5230, 
    target=0x2b4ce3a92400, tmode=VOIDmode, modifier=EXPAND_NORMAL, alt_rtl=0x0)
    at /space/rguenther/src/svn/trunk/gcc/expr.c:7094
#6  0x0000000000a95a45 in expand_expr (exp=0x2b4ce44e5230, 
    target=0x2b4ce3a92400, mode=VOIDmode, modifier=EXPAND_NORMAL)
    at /space/rguenther/src/svn/trunk/gcc/expr.h:514
#7  0x0000000000a977db in expand_expr_stmt (exp=0x2b4ce44e5230)
    at /space/rguenther/src/svn/trunk/gcc/stmt.c:1361
#8  0x0000000000fd8e9a in expand_gimple_basic_block (bb=0x2b4ce44c8f00)
    at /space/rguenther/src/svn/trunk/gcc/cfgexpand.c:1609
#9  0x0000000000fda700 in tree_expand_cfg ()
    at /space/rguenther/src/svn/trunk/gcc/cfgexpand.c:1918

thus from expanding another function.

Bummer.
Comment 3 Richard Biener 2008-01-18 15:09:41 UTC
I have a patch.
Comment 4 Richard Biener 2008-01-21 09:34:30 UTC
Fixed.
Comment 5 Richard Biener 2008-01-21 09:35:04 UTC
Subject: Bug 34850

Author: rguenth
Date: Mon Jan 21 09:34:19 2008
New Revision: 131690

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131690
Log:
2008-01-21  Richard Guenther  <rguenther@suse.de>

	PR c++/34850
	cp/
	* error.c (cp_print_error_function): Deal with recursive
	BLOCK trees.

	* g++.dg/torture/pr34850.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr34850.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/error.c
    trunk/gcc/testsuite/ChangeLog