This produces a warning in C++20:
/home/test/src/gcc/gcc/analyzer/constraint-manager.cc: In member function ‘bool ana::constraint_manager::operator==(const ana::constraint_manager&) const’:
/home/test/src/gcc/gcc/analyzer/constraint-manager.cc:1610:42: warning: C++20 says that these are ambiguous, even though the second is reversed:
1610 | if (!(*ec == *other.m_equiv_classes[i]))
| ^
/home/test/src/gcc/gcc/analyzer/constraint-manager.cc:1178:1: note: candidate 1: ‘bool ana::equiv_class::operator==(const ana::equiv_class&)’
1178 | equiv_class::operator== (const equiv_class &other)
| ^~~~~~~~~~~
/home/test/src/gcc/gcc/analyzer/constraint-manager.cc:1178:1: note: candidate 2: ‘bool ana::equiv_class::operator==(const ana::equiv_class&)’ (reversed)
/home/test/src/gcc/gcc/analyzer/constraint-manager.cc:1178:1: note: try making the operator a ‘const’ member function
gcc/analyzer/ChangeLog:
* constraint-manager.cc (equiv_class::operator==): Add const
qualifier.
* constraint-manager.h (equiv_class::operator==): Likewise.
meaningful. */
bool
-equiv_class::operator== (const equiv_class &other)
+equiv_class::operator== (const equiv_class &other) const
{
if (m_constant != other.m_constant)
return false; // TODO: use tree equality here?
equiv_class (const equiv_class &other);
hashval_t hash () const;
- bool operator== (const equiv_class &other);
+ bool operator== (const equiv_class &other) const;
void add (const svalue *sval);
bool del (const svalue *sval);