https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70909
--- Comment #50 from Mark Wielaard <mark at gcc dot gnu.org> --- (In reply to Mark Wielaard from comment #49) > (In reply to Pedro Alves from comment #48) > > GDB is released separately from binutils though, and GDB 8.0 is going to > > branch very soon. IWBN to have this in the binutils-gdb repo by then. > > Trying to integrate this into binutils-gdb produces a large number of > unexpected failures in the gdb testsuite. This is caused by gdb doing its own memory management to reuse demangle_components. Whenever gdb d_grabs a new struct demangle_component we now need to initialize d_printing to zero. diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index fd1e949..c997f20 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -190,6 +190,7 @@ fill_comp (enum demangle_component_type d_type, struct demangle_component *lhs, struct demangle_component *ret = d_grab (); int i; + ret->d_printing = 0; i = cplus_demangle_fill_component (ret, d_type, lhs, rhs); gdb_assert (i); @@ -201,6 +202,7 @@ make_empty (enum demangle_component_type d_type) { struct demangle_component *ret = d_grab (); ret->type = d_type; + ret->d_printing = 0; return ret; } @@ -210,6 +212,7 @@ make_operator (const char *name, int args) struct demangle_component *ret = d_grab (); int i; + ret->d_printing = 0; i = cplus_demangle_fill_operator (ret, name, args); gdb_assert (i); @@ -222,6 +225,7 @@ make_dtor (enum gnu_v3_dtor_kinds kind, struct demangle_component *name) struct demangle_component *ret = d_grab (); int i; + ret->d_printing = 0; i = cplus_demangle_fill_dtor (ret, kind, name); gdb_assert (i); @@ -234,6 +238,7 @@ make_builtin_type (const char *name) struct demangle_component *ret = d_grab (); int i; + ret->d_printing = 0; i = cplus_demangle_fill_builtin_type (ret, name); gdb_assert (i); @@ -246,6 +251,7 @@ make_name (const char *name, int len) struct demangle_component *ret = d_grab (); int i; + ret->d_printing = 0; i = cplus_demangle_fill_name (ret, name, len); gdb_assert (i); But maybe the cplus_demangle_fill_xxx functions should do this initializing instead? In that case gdb only needs to handle initializing d_printing for its own make_empty function.