While looking at something else, I stumbled upon this problem.
When comparing a class, equals first calls the overload for
class_or_union to compare data members. If we are in the process of
type canonicalization, the right hand side operand might be
"canonical-type-propagated", during that call to the overload. In
other words, it can inherit the canonical type of the left-hand-side
operand. The problem is that that canonical type propagation, if it
happens, is too early because this equals function still needs to
compare other things like virtual member functions etc. So, the
original intend of the code was to erase the canonical type that might
have been propagated. This is all and well.
The problem however is that the code /always/ erases the canonical
type of the right hand side operand, even if it was the result of the
propagation optimization long before it entered this equals function.
Oops.
This patch fixes that issue.
* src/abg-ir.cc (equals): In the overload for const class_decl&,
do not cancel the propagated canonical type if the propagation is
not the result of invoking the equals overload for class_or_union.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED(static_cast<const class_or_union&>(l),
static_cast<const class_or_union&>(r));
+ bool had_canonical_type = !!r.get_naked_canonical_type();
bool result = true;
if (!equals(static_cast<const class_or_union&>(l),
static_cast<const class_or_union&>(r),
// canonical type propagation, then cancel that because it's too
// early to do that at this point. We still need to compare bases
// virtual members.
- maybe_cancel_propagated_canonical_type(r);
+ if (!had_canonical_type)
+ maybe_cancel_propagated_canonical_type(r);
// Compare bases.
if (l.get_base_specifiers().size() != r.get_base_specifiers().size())