Index: cp/cp-objcp-common.c =================================================================== --- cp/cp-objcp-common.c (revision 251553) +++ cp/cp-objcp-common.c (working copy) @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. #include "coretypes.h" #include "cp-tree.h" #include "cp-objcp-common.h" +#include "stor-layout.h" #include "dwarf2.h" /* Special routine to get the alias set for C++. */ @@ -138,8 +139,20 @@ tree cp_get_debug_type (const_tree type) { if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type)) - return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type), - TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))); + { + /* We cannot call build_offset_type here because the function uses the + type canonicalization hashtable, which is GC-ed, so its behavior + depends on the actual collection points. Since we are building these + types on the fly for the debug info, they are not attached to any + GC root and will always be swept, so we would make the contents of + the debug info depend on the collection points. */ + tree t = make_node (OFFSET_TYPE); + TYPE_OFFSET_BASETYPE (t) + = TYPE_MAIN_VARIANT (TYPE_PTRMEMFUNC_OBJECT_TYPE (type)); + TREE_TYPE (t) = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)); + layout_type (t); + return t; + } return NULL_TREE; } Index: testsuite/g++.dg/debug/dwarf2/ref-3.C =================================================================== --- testsuite/g++.dg/debug/dwarf2/ref-3.C (revision 251553) +++ testsuite/g++.dg/debug/dwarf2/ref-3.C (working copy) @@ -3,7 +3,7 @@ // { dg-final { scan-assembler-times " DW_AT_reference" 5 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times " DW_AT_rvalue_reference" 5 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_subroutine_type" 6 { xfail *-*-aix* } } } -// { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_ptr_to_member_type" 7 { xfail *-*-aix* } } } +// { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_ptr_to_member_type" 13 { xfail *-*-aix* } } } // { dg-final { scan-assembler-times " DW_AT_use_location" 1 { xfail *-*-aix* } } } struct S