diff --git a/genaisrc/FixBuildIssue.genai.mjs b/genaisrc/FixBuildIssue.genai.mjs new file mode 100644 index 0000000000..c4b9dfb03b --- /dev/null +++ b/genaisrc/FixBuildIssue.genai.mjs @@ -0,0 +1,21 @@ + +def("FILE", env.files) + +def("ERR", "/home/nbjorner/z3/src/nlsat/nlsat_simple_checker.cpp: In member function ‘bool nlsat::simple_checker::imp::Endpoint::operator==(const nlsat::simple_checker::imp::Endpoint&) const’:\ +/home/nbjorner/z3/src/nlsat/nlsat_simple_checker.cpp:63:82: warning: C++20 says that these are ambiguous, even though the second is reversed:\ + 63 | if (!m_inf && !rhs.m_inf && m_open == rhs.m_open && m_val == rhs.m_val) {\ + | ^~~~~\ +In file included from /home/nbjorner/z3/src/util/mpz.h:26,\ + from /home/nbjorner/z3/src/util/mpq.h:21,\ + from /home/nbjorner/z3/src/util/rational.h:21,\ + from /home/nbjorner/z3/src/math/polynomial/algebraic_numbers.h:21,\ + from /home/nbjorner/z3/src/nlsat/nlsat_simple_checker.h:20,\ + from /home/nbjorner/z3/src/nlsat/nlsat_simple_checker.cpp:1:\ +/home/nbjorner/z3/src/util/scoped_numeral.h:96:17: note: candidate 1: ‘bool operator==(const _scoped_numeral&, const _scoped_numeral::numeral&)’\ + 96 | friend bool operator==(_scoped_numeral const & a, numeral const & b) {\ + | ^~~~~~~~\ +/home/nbjorner/z3/src/util/scoped_numeral.h:96:17: note: candidate 2: ‘bool operator==(const _scoped_numeral&, const _scoped_numeral::numeral&)’ (reversed)") + +$`You are an expert C++ programmer. +Your task is to fix the compilation bug reported in the error message ERR. +How should FILE be changed to fix the error message?` diff --git a/src/util/scoped_numeral.h b/src/util/scoped_numeral.h index f70f5f1855..0bbae754ba 100644 --- a/src/util/scoped_numeral.h +++ b/src/util/scoped_numeral.h @@ -97,10 +97,19 @@ class _scoped_numeral { return a.m().eq(a, b); } + friend bool operator==(_scoped_numeral const & a, _scoped_numeral const & b) { + return a.m().eq(a.m_num, b.m_num); + } + friend bool operator!=(_scoped_numeral const & a, numeral const & b) { return !a.m().eq(a, b); } + friend bool operator!=(_scoped_numeral const & a, _scoped_numeral const & b) { + return !(a == b); + } + + friend bool operator<(_scoped_numeral const & a, numeral const & b) { return a.m().lt(a, b); }