Bug 34206 - [4.3 Regression] ICE in retrieve_local_specialization
Summary: [4.3 Regression] ICE in retrieve_local_specialization
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: Jason Merrill
URL:
Keywords: ice-on-valid-code
: 34208 34541 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-11-23 13:20 UTC by Richard Biener
Modified: 2007-12-26 14:06 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-11-24 06:10:36


Attachments
reduced testcase (1.16 KB, text/plain)
2007-11-23 13:21 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-11-23 13:20:56 UTC
./cc1plus -quiet -O2 bug-343711_storage.min.ii

Program received signal SIGSEGV, Segmentation fault.
0x00000000010aa445 in htab_find_with_hash (htab=0x0, element=0x2b7075926540, 
    hash=246566056) at /space/rguenther/src/svn/trunk/libiberty/hashtab.c:566
566       htab->searches++;
(gdb) up
#1  0x000000000047ab19 in retrieve_local_specialization (tmpl=0x2b7075926540)
    at /space/rguenther/src/svn/trunk/gcc/cp/pt.c:979
979                                               htab_hash_pointer (tmpl));
Comment 1 Richard Biener 2007-11-23 13:21:37 UTC
Created attachment 14626 [details]
reduced testcase
Comment 2 Martin Michlmayr 2007-11-23 18:25:29 UTC
*** Bug 34208 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Jelinek 2007-11-23 20:39:39 UTC
Introduced by
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128681
Comment 4 Jakub Jelinek 2007-11-23 21:11:02 UTC
In particular, this is caused by the pt.c (tsubst) change:
@@ -8555,16 +8545,15 @@
   gcc_assert (type != unknown_type_node);
 
   /* Reuse typedefs.  We need to do this to handle dependent attributes,
-     specifically attribute aligned.  */
+     such as attribute aligned.  */
   if (TYPE_P (t)
       && TYPE_NAME (t)
-      && !MAYBE_TAGGED_TYPE_P (t)
-      && TREE_CODE (t) != TEMPLATE_TEMPLATE_PARM
-      && TREE_CODE (t) != UNBOUND_CLASS_TEMPLATE)
+      && TYPE_NAME (t) != TYPE_MAIN_DECL (t))
     {
       tree decl = TYPE_NAME (t);
       
-      if (DECL_CLASS_SCOPE_P (decl))
+      if (DECL_CLASS_SCOPE_P (decl)
+          && CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl)))
         {
           tree tmpl = most_general_template (DECL_TI_TEMPLATE (decl));
           tree gen_args = tsubst (DECL_TI_ARGS (decl), args, complain, in_decl);
           r = retrieve_specialization (tmpl, gen_args, false);
         }
       else if (DECL_FUNCTION_SCOPE_P (decl))
         r = retrieve_local_specialization (decl);
       else
         r = NULL_TREE;

In this case t is RECORD_TYPE in function scope, so MAYBE_TAGGED_TYPE_P was true on it, but this (fn_type_unification) wasn't called from instantiate_decl
and so local_specializations is NULL.

I wonder if just
-       else if (DECL_FUNCTION_SCOPE_P (decl))
+       else if (DECL_FUNCTION_SCOPE_P (decl) && local_specializations)
wouldn't be best fix for this, there are already other places which guard
retrieve_local_specialization calls by this condition.
Comment 5 Jason Merrill 2007-12-18 22:25:33 UTC
Subject: Bug 34206

Author: jason
Date: Tue Dec 18 22:25:20 2007
New Revision: 131044

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131044
Log:
        PR c++/34206
        * pt.c (tsubst_aggr_type): Do nothing if the type already doesn't
        use template parms.
        (dependent_type_p_r): Handle the domain of an array.

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

Comment 6 Jason Merrill 2007-12-18 22:44:02 UTC
fixed
Comment 7 Volker Reichelt 2007-12-26 14:06:25 UTC
*** Bug 34541 has been marked as a duplicate of this bug. ***