The ability of an ordering function that is not a Strict Weak Ordering to cause runtime segfaults when used with sort or an ordered container is .. one of the top vexing things in C++. I think that we naively expect that such a sort predicate could lead to the items in the sorted range in an unspecified order, but not that it could actually segfault! yes, the standard says this is undefined behavior, but boy -- I wish the standard said something else instead. This is particularly problematic because it means that you can't allow user-defined sort predicates. It's easy to imagine a model where no sort predicate a user could write would cause out of bounds memory accesses! but instead, ... yes there are.