public inbox for
 help / color / mirror / Atom feed
* [PATCH, applied] ir: Don't overdo canonical type propagation control when comparing classes
@ 2022-09-05 16:10 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2022-09-05 16:10 UTC (permalink / raw)
  To: libabigail


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.

This patch fixes that issue.

	* src/ (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 <>
Applied to master.

 src/ | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/ b/src/
index a2eb8a02..7c8b6640 100644
--- a/src/
+++ b/src/
@@ -23587,6 +23587,7 @@ equals(const class_decl& l, const class_decl& r, change_kind* k)
   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),
@@ -23609,7 +23610,8 @@ equals(const class_decl& l, const class_decl& r, change_kind* k)
   // 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())


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-05 16:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 16:10 [PATCH, applied] ir: Don't overdo canonical type propagation control when comparing classes Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).