https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79289
Ian Lance Taylor <ian at airs dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aoliva at gcc dot gnu.org, | |jakub at gcc dot gnu.org, | |jason at gcc dot gnu.org --- Comment #1 from Ian Lance Taylor <ian at airs dot com> --- I think the bug is a mismatch in how the code determines the base type to use for the DIE in this change: 2016-11-03 Jakub Jelinek <ja...@redhat.com> Alexandre Oliva <aol...@redhat.com> Jason Merrill <ja...@redhat.com> PR debug/28767 PR debug/56974 * langhooks.h (struct lang_hooks_for_types): Add type_dwarf_attribute langhook. * langhooks.c (lhd_type_dwarf_attribute): New function. * langhooks-def.h (lhd_type_dwarf_attribute): Declare. (LANG_HOOKS_TYPE_DWARF_ATTRIBUTE): Define. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_TYPE_DWARF_ATTRIBUTE. (check_qualified_type, check_aligned_type): Call it. * dwarf2out.c (modified_type_die): Don't use type_main_variant for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with check_base_type and check_lang_type. (gen_ptr_to_mbr_type_die): If lookup_type_die is already non-NULL, return early. For pointer-to-data-member add DW_AT_use_location attribute. (gen_subroutine_type_die): Add DW_AT_{,rvalue_}reference attribute if needed. (gen_type_die_with_usage): Don't use type_main_variant for FUNCTION_TYPE or METHOD_TYPE, instead walk over variants with check_base_type and check_lang_type. Formatting fixes. Call get_debug_type langhook. The problem is that the DIE is stored with one type variant in gen_type_die_with_usage (the last matching variant), but looked up with a different type variant in modified_type_die (the first matching variant). This patch seems to fix the problem, but I can't tell whether this is correct or whether the other obvious change is correct. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 244166) +++ gcc/dwarf2out.c (working copy) @@ -24395,8 +24395,13 @@ gen_type_die_with_usage (tree type, dw_d but try to canonicalize. */ tree main = TYPE_MAIN_VARIANT (type); for (tree t = main; t; t = TYPE_NEXT_VARIANT (t)) - if (check_base_type (t, main) && check_lang_type (t, type)) - type = t; + { + if (check_base_type (t, main) && check_lang_type (t, type)) + { + type = t; + break; + } + } } else if (TREE_CODE (type) != VECTOR_TYPE && TREE_CODE (type) != ARRAY_TYPE)