This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/66786] [5/6 Regression] ICE: Segmentation fault


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66786

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like the field LAMBDA_TYPE_EXTRA_SCOPE has what we need.  I am testing
this patch:

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4d405cf..5c344c1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -369,16 +369,20 @@ template_class_depth (tree type)
 {
   int depth;

-  for (depth = 0;
-       type && TREE_CODE (type) != NAMESPACE_DECL;
-       type = (TREE_CODE (type) == FUNCTION_DECL)
-        ? CP_DECL_CONTEXT (type) : CP_TYPE_CONTEXT (type))
+  for (depth = 0; type && TREE_CODE (type) != NAMESPACE_DECL; )
     {
       tree tinfo = get_template_info (type);

       if (tinfo && PRIMARY_TEMPLATE_P (TI_TEMPLATE (tinfo))
          && uses_template_parms (INNERMOST_TEMPLATE_ARGS (TI_ARGS (tinfo))))
        ++depth;
+
+      if (VAR_OR_FUNCTION_DECL_P (type))
+       type = CP_DECL_CONTEXT (type);
+      else if (LAMBDA_TYPE_P (type))
+       type = LAMBDA_TYPE_EXTRA_SCOPE (type);
+      else
+       type = CP_TYPE_CONTEXT (type);
     }

   return depth;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]