When we face two equivalent highly recursive structs/classes, it can
happen that a given data member be added twice to the type. When
comparing two versions of a binary in which the data member happens to
have been removed from the second version, we thus trigger an assert
because a given data member has been "removed twice".
This happens on the example provided in PR libabigail/17948 -- which
is too big to be added to the test suite.
This patch hopefully fixes the issue by looking harder at the data
structure to make sure that we don't add the same data member twice.
* src/abg-dwarf-reader.cc (add_or_update_class_type): After a we
try to create a data member type, look *again* if the data member
wasn't added recursively by the creation of the data member type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
if (!t)
continue;
+ // The call to build_ir_node_from_die above could have
+ // triggered the adding of a data member named 'n' into
+ // result. So let's check again if the variable is
+ // already a member of this class.
+ if (lookup_var_decl_in_scope(n, result))
+ continue;
+
if (!is_static)
// We have a non-static data member. So this class
// cannot be a declaration-only class anymore, even if