From: Jonathan Wakely Date: Thu, 27 Nov 2025 16:13:44 +0000 (+0000) Subject: analyzer: Add missing 'const' to equiv_class::operator== X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfd17e05f9e983660b87e603c062918d2d173fc3;p=thirdparty%2Fgcc.git analyzer: Add missing 'const' to equiv_class::operator== 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. --- diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 58c60feae36..c8cc71593cc 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -1175,7 +1175,7 @@ equiv_class::hash () const 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? diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h index 4339ea665d8..38686b7e696 100644 --- a/gcc/analyzer/constraint-manager.h +++ b/gcc/analyzer/constraint-manager.h @@ -258,7 +258,7 @@ public: 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);