This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/71545] [6/7 Regression] Incorrect irreflexive comparison debug check in std::lower_bound


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71545

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The irreflexive assertion is incorrect for lexicographical compare too:

#include <algorithm>

struct X { };

bool operator<(X, int) { return true; }
bool operator<(int, X) { return false; }

// Not a strict weak order
bool operator<(X, X) { return true; }

int main()
{
  X x[1];
  int i[1];
  std::lexicographical_compare(x, x+1, i, i+1);
}

This fails in Debug Mode because operator<(X, X) doesn't define a strict weak
order, but that operator is not used by the algorithm.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]