https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84580
Bug ID: 84580 Summary: Equality and relational ops for containers behave differently in Debug Mode Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This passes in normal mode but fails the second assertion when compiled with -D_GLIBCXX_DEBUG #include <cassert> #include <vector> struct foo { }; typedef std::vector<foo*> vect; bool operator==(const vect&, const vect&) { return true; } int main() { vect v1; vect v2; v1.push_back(nullptr); assert(v1 == v2); assert(!(v1 != v2)); } The problem is that in Debug Mode (v1 != v2) doesn't call (v1 == v2) which would use the custom ::operator== overload. Instead it calls (v1.base() != v2.base()) which then calls operator==, but with arguments of type std::__cxx1998::vector, and so won't use the ::operator== overload. I think we need to make std::__debug::operator!= use == so that ADL can find the same overload as would be found in normal mode, and similarly for >, <= and >= (from Table 77, Optional container operations).