https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116219
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> --- DECL_NAMELESS VAR_DECL names don't leak into debug info. The -fcompare-debug failures I believe are solely because these fancy names appear in the -fdump-final-insns= dumps (e.g. inside of MEM_EXPRs or REG_EXPRs). And, they wouldn't appear there if it was just the VAR_DECLs created by SRA with DECL_NAMELESS set, we have that /* For -fcompare-debug don't dump DECL_NAMELESS names at all, -g might have created more fancy names and their indexes could get out of sync. Usually those should be DECL_IGNORED_P too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy names, let's hope those never get out of sync after doing the dump_fancy_name sanitization. */ else if ((flags & TDF_COMPARE_DEBUG) && DECL_NAMELESS (node) && DECL_IGNORED_P (node)) name = NULL_TREE; /* For DECL_NAMELESS names look for embedded uids in the names and sanitize them for TDF_NOUID. */ else if ((flags & TDF_NOUID) && DECL_NAMELESS (node)) dump_fancy_name (pp, name); else pp_tree_identifier (pp, name); where dump_fancy_name will try to look for the Dnnnnn$ inside of it, so offset$D94316$_M_impl$D93629$_M_start_588 would be either not dumped as just _588 or offset$Dxxxx$_M_impl$Dxxxx$_M_start_588 But the problem is that all the get_name users I've listed above grab the name and most of them create new VAR_DECLs out of that and those aren't DECL_NAMELESS anymore and even if we fixed that, additionally those $s in the names are replaced with _s. So, the question was how best to propagate next to const char *name a bool nameless flag so that we can avoid removing those $s and ensure DECL_NAMELESS is set. Maybe also whether we should have similar flag to DECL_NAMELESS on SSA_NAMEs in case they have just an IDENTIFIER_NODE rather than underlying VAR_DECL. One C++-ish way would be to create a small class containing const char *_M_name; bool _M_nameless; with a constructor from const char * which sets the flag to false, make it default copyable/destructible so that it is passed as a struct and change create_tmp_var* to accept that.