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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note while the patch fixes the reported issue it still ICEs the same way
when compiling with -g0 and linking with -g (as I would have expected).

That would be fixed by sth like the following but that then hides
issues with consistent -g as we ran into.  It might be instead interesting
to make it more consistently fail by asserting early_dwarf here ...
(but I expect that to blow up in our face)

So I'm not going to fix this right now but will open a new bug for it.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index bd45e0b0685..3eaa032bb95 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23732,12 +23732,13 @@ gen_variable_die (tree decl, tree origin, dw_die_ref
context_die)
   else
     add_name_and_src_coords_attributes (var_die, decl, no_linkage_name);

-  if ((origin == NULL && !specialization_p)
-      || (origin != NULL
-         && !DECL_ABSTRACT_P (decl_or_origin)
-         && variably_modified_type_p (TREE_TYPE (decl_or_origin),
-                                      decl_function_context
-                                                       (decl_or_origin))))
+  if (early_dwarf
+      && ((origin == NULL && !specialization_p)
+         || (origin != NULL
+             && !DECL_ABSTRACT_P (decl_or_origin)
+             && variably_modified_type_p (TREE_TYPE (decl_or_origin),
+                                          decl_function_context
+                                            (decl_or_origin)))))
     {
       tree type = TREE_TYPE (decl_or_origin);

Reply via email to