DWARF reader: avoid C++20 operator!= overload ambiguity
authorGiuliano Procida <gprocida@google.com>
Mon, 9 Jan 2023 09:20:44 +0000 (09:20 +0000)
committerDodji Seketeli <dodji@redhat.com>
Mon, 9 Jan 2023 15:52:24 +0000 (16:52 +0100)
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

index e3a1348de59586ab453481db7110e2583cbf72f2..ce6b52d4016d81bcbcec2b14e410fd4728b55ae5 100644 (file)
@@ -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;