------- Comment #3 from matz at gcc dot gnu dot org 2008-01-22 18:28 ------- The problem is, that gen_type_die() generates a DIE only for the main variant of the given type. But lookup_type_die looks in the type itself. In the example the type in question is "const A", for which no DIE exists already. So force_type_die() goes into the if(), calls gen_type_die which generated a DIE for "A" (in fact that already exists, so it just returns). But a DIE for "const A" still doesn't exist of course. The example can be made to compile to force such existence, e.g. by adding a member to "A":
struct A { ... void cmem() const; }; There are two ways of fixing this: 1) making sure, that "const A" (the tree node) refers to the DIE for "A", i.e. losing the qualifiers. One could ensure this in either force_type_die or even gen_type_die by calling equate_type_number_to_die. 2) ensure that force_type_die() really creates a DIE which reflects type (and not just the main variant). With the above test one can see, that the intention was, that the AT_import decl really comes inside the DIE for "const A". So, that speaks for option 2. This is also the natural choice as a function named "force_type_die" surely should generate a DIE for that very type and not some other variant of it. The below patch would implement this. Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 131712) +++ dwarf2out.c (working copy) @@ -13736,11 +13736,8 @@ force_type_die (tree type) else context_die = comp_unit_die; - type_die = lookup_type_die (type); - if (type_die) - return type_die; - gen_type_die (type, context_die); - type_die = lookup_type_die (type); + type_die = modified_type_die (type, TYPE_READONLY (type), + TYPE_VOLATILE (type), context_die); gcc_assert (type_die); } return type_die; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34895