https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85176
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P1 Target Milestone|--- |8.0 Summary|ICE in force_decl_die, at |[8 Regression] ICE in |dwarf2out.c:25910 |force_decl_die, at | |dwarf2out.c:25910 --- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- In the end caused by -g1 not generating DIEs for NAMESPACE_DECLs. At compile-time the DIEs are rooted at comp_unit_die () but LTO expects to re-generate the DIE child->parent relationship via DECL/TYPE_CONTEXT, we do not stream that (because DIEs lack a back-mapping to the tree it was generated off, rightfully so). So we have to mimick that in dwarf2out_register_external_die. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 259069) +++ gcc/dwarf2out.c (working copy) @@ -5903,8 +5903,13 @@ dwarf2out_register_external_die (tree de } else ctx = DECL_CONTEXT (decl); + /* Peel types in the context stack. */ while (ctx && TYPE_P (ctx)) ctx = TYPE_CONTEXT (ctx); + /* Likewise namespaces in case we do not want to emit DIEs for them. */ + if (debug_info_level <= DINFO_LEVEL_TERSE) + while (ctx && TREE_CODE (ctx) == NAMESPACE_DECL) + ctx = DECL_CONTEXT (ctx); if (ctx) { if (TREE_CODE (ctx) == BLOCK)