On Thu, 21 Jun 2018, Jan Hubicka wrote: > Hi, > this problem here seems to be that is_cxx returns true and at the same > time auto_die and decltype_auto_die is not initialized. Here die==NULL > and we end up calling add_type_attribute for random reasons. > > I am testing the following but I am not sure it is proper fix. Are > we supposed to handle auto dies here somehow?
We're not supposed to run into the DW_AT_specification case in late dwarf, but yes, this explains the issue somewhat but the specification is supposed to be generated early already and the late dwarf should refer to it via DW_AT_abstract_origin. I'll have to dig into the testcase a bit myself. > Index: dwarf2out.c > =================================================================== > --- dwarf2out.c (revision 261841) > +++ dwarf2out.c (working copy) > @@ -22830,7 +22830,8 @@ gen_subprogram_die (tree decl, dw_die_re > if (is_cxx () && debug_info_level > DINFO_LEVEL_TERSE) > { > dw_die_ref die = get_AT_ref (old_die, DW_AT_type); > - if (die == auto_die || die == decltype_auto_die) > + /* In LTO auto_die and decltype_auto_die may be NULL. */ > + if (die && (die == auto_die || die == decltype_auto_die)) > add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)), > TYPE_UNQUALIFIED, false, context_die); > }