From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E58953858027; Thu, 13 Oct 2022 08:04:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E58953858027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665648268; bh=6JcdtwBRTpLlR32FfQvB9xQUZqPwEqdGJQjlotleGpQ=; h=From:To:Subject:Date:From; b=wovYagFoUAj66eDDnn6h5dv7gK0aasH63dihRDdWNOsKZ3EpduoibCHoBSi4KmYKT QOjCH5mT0WAy63Ww6YQ4U4eCAlvCPwMYgl1FXBUAaWY/rhK4UNTdy5ZBlIzoF+/YSJ rXXbTqoDgATMCjUjSM2JIsZVNMfXtxREgGP+71FM= From: "gprocida at google dot com" To: libabigail@sourceware.org Subject: [Bug default/29679] New: C++20 compilation failure - ambiguous comparisons Date: Thu, 13 Oct 2022 08:04:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: libabigail X-Bugzilla-Component: default X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gprocida at google dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: dodji at redhat dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29679 Bug ID: 29679 Summary: C++20 compilation failure - ambiguous comparisons Product: libabigail Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: default Assignee: dodji at redhat dot com Reporter: gprocida at google dot com CC: libabigail at sourceware dot org Target Milestone: --- This was reported internally, along with a proposed fix. To reproduce, change the C++ standard in configure.ac from 11 and 20, reconfigure and rebuild. With GCC: CXX abg-dwarf-reader.lo ../../src/abg-dwarf-reader.cc: In function =E2=80=98bool abigail::dwarf_reader::op_is_control_flow(Dwarf_Op*, size_t, size_t, size_t= &, dwarf_expr_eval_context&)=E2=80=99: ../../src/abg-dwarf-reader.cc:9007:16: error: ambiguous overload for =E2=80=98operator!=3D=E2=80=99 (operand types are =E2=80=98abigail::dwarf_r= eader::expr_result=E2=80=99 and =E2=80=98int=E2=80=99) 9007 | if (val1 !=3D 0) | ~~~~ ^~ ~ | | | | | int | abigail::dwarf_reader::expr_result ../../src/abg-dwarf-reader.cc:1735:3: note: candidate: =E2=80=98bool abigail::dwarf_reader::expr_result::operator=3D=3D(const abigail::dwarf_reader::expr_result&) const=E2=80=99 (rewritten) 1735 | operator=3D=3D(const expr_result& o) const | ^~~~~~~~ ../../src/abg-dwarf-reader.cc:9007:16: note: candidate: =E2=80=98operator!= =3D(int64_t {aka long int}, int)=E2=80=99 (built-in) 9007 | if (val1 !=3D 0) | ~~~~~^~~~ With Clang there are several more errors, but they are explained by: https://github.com/llvm/llvm-project/issues/57711 The fix that was proposed internally was: --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -1638,6 +1638,10 @@ public: {return const_value_ =3D=3D o.const_value_ && is_const_ =3D=3D o.is_cons= t_;} bool + operator!=3D(const expr_result& o) const + {return !(*this =3D=3D o);} + + bool operator>=3D(const expr_result& o) const {return const_value_ >=3D o.const_value_;} @@ -8364,7 +8368,7 @@ op_is_control_flow(Dwarf_Op* expr, case DW_OP_bra: val1 =3D ctxt.pop(); - if (val1 !=3D 0) + if (0 !=3D val1) index +=3D val1.const_value() - 1; break; And the accompanying explanation was: 1. operator=3D=3D(const expr_result&, const expr_result&) is ambiguous beca= use C++20 could call this with args (val1, 0) or with reversed args (0, val1). This is because of implicit conversion from int to expr_result. Adding operator!=3D disables argument reversal and resolves the ambiguity. 2. 0 =3D=3D val1 is then illegal because the LHS (int) does not provide ope= rator=3D=3D. When argument reversal is disabled, the LHS should provide operator=3D=3D. (Same for !=3D). I'll be honest and say that I haven't followed the details of this. However, another way to resolve the issue might be to eliminate the implicit conversion - these tend to be sources of other surprises anyway. Regards, Giuliano. --=20 You are receiving this mail because: You are on the CC list for the bug.=