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

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jun 17 15:04:00 GMT 2016


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.


More information about the Gcc-bugs mailing list