C++/DWARF2 build failure in libstdc++

Jim Wilson wilson@cygnus.com
Tue Oct 19 17:02:00 GMT 1999


C++ has been broken for targets that use DWARF2 since Sept 25.  It was
broken by this change:

1999-09-25  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (pushdecl): Put global friend functions in namespace binding
	level, not the class binding level.

The breakage shows up as an abort in gen_type_die while compiling
libstdc++/valarray.cc.

Here is a simple testcase.  Compile with -O -gdwarf-2 to see the failure.

template<template<class> class _Oper,
    template<class, class> class _Meta1,
    template<class, class> class _Meta2,
    class _Dom1, class _Dom2> class _BinClos;

We call pushdecl with a TYPE_DECL with type TEMPLATE_TYPE_PARM and with no
DECL_NAME.  Near the top, DECL_CONTEXT is deliberately not set, because
this is a template parameter, and template parameters have no context.
Near the bottom, we test DECL_CONTEXT, and because it is NULL, the decl
is put in the global binding level instead of the current binding level.
This seems wrong.  This causes dwarf2out.c to try to emit debug info, and
it fails because it doesn't handle TEMPLATE_TYPE_PARM.

Normally, a TEMPLATE_TYPE_PARM TYPE_DECL will have DECL_NAME set, and
we take a different path that leads to a push_local_binding call that
seems to do the right thing.  We only get the failure if there is no name.
This seems to require the template<class, class> construct to trigger.

Jim


More information about the Gcc-bugs mailing list