https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96690
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Without LTO, gen_remaining_tmpl_value_param_die_attribute will try to get it, and will mangle the foo decl, but shortly after will throw it away due to const_ok_for_output failing on it. Your patch makes sense to me.