public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] DWARF reader: avoid C++20 operator!= overload ambiguity
@ 2023-01-09  9:20 Giuliano Procida
  2023-01-09 16:03 ` Dodji Seketeli
  0 siblings, 1 reply; 2+ messages in thread
From: Giuliano Procida @ 2023-01-09  9:20 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, gprocida, maennich, sidnayyar, vvvvvv

C++20 automatically generates overloads for certain comparison
operators based on others and this can create ambiguity with older
code. The type expr_result has various operators defined and comparing
expr_result != int becomes ambiguous.

This change just avoids this comparison by extracting the underlying
value, rather than making changes to the type itself. There should be
no change in behaviour and no tests are affected.

	* (src/abg-dwarf-reader.cc) op_is_control_flow: In the
	DW_OP_bra case, when testing the popped value, use the
	expr_result's const_value explicitly.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-dwarf-reader.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index e3a1348d..ce6b52d4 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -8279,7 +8279,7 @@ op_is_control_flow(Dwarf_Op* expr,
 
     case DW_OP_bra:
       val1 = ctxt.pop();
-      if (val1 != 0)
+      if (val1.const_value() != 0)
 	index += val1.const_value() - 1;
       break;
 
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] DWARF reader: avoid C++20 operator!= overload ambiguity
  2023-01-09  9:20 [PATCH] DWARF reader: avoid C++20 operator!= overload ambiguity Giuliano Procida
@ 2023-01-09 16:03 ` Dodji Seketeli
  0 siblings, 0 replies; 2+ messages in thread
From: Dodji Seketeli @ 2023-01-09 16:03 UTC (permalink / raw)
  To: Giuliano Procida; +Cc: libabigail, kernel-team, maennich, sidnayyar, vvvvvv

Hello Giuliano,

First of all, Happy New Year to you and your beloved ones!

Giuliano Procida <gprocida@google.com> a écrit:

> C++20 automatically generates overloads for certain comparison
> operators based on others and this can create ambiguity with older
> code. The type expr_result has various operators defined and comparing
> expr_result != int becomes ambiguous.
>
> This change just avoids this comparison by extracting the underlying
> value, rather than making changes to the type itself. There should be
> no change in behaviour and no tests are affected.
>
> 	* (src/abg-dwarf-reader.cc) op_is_control_flow: In the
> 	DW_OP_bra case, when testing the popped value, use the
> 	expr_result's const_value explicitly.
>
> Signed-off-by: Giuliano Procida <gprocida@google.com>

Applied to the master branch, thanks!

[...]

Cheers,

-- 
		Dodji

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-09 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09  9:20 [PATCH] DWARF reader: avoid C++20 operator!= overload ambiguity Giuliano Procida
2023-01-09 16:03 ` 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).