<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 12, 2016 at 10:27 PM, Yury Gribov via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
As for C++11, it has for e.g. srtd::sort:<br>
<br>
"Requires: operator< (for the version with no arguments) or comp (for the version with a comparison argument) defines a strict weak ordering (25.4)."<br>
<br>
which also sounds like UB.</blockquote><div><br></div><div>Exactly correct.</div><div>If your comparison operator does not define a SWO, then you have no guarantees of the results. Crashes are common.</div><div><br></div><div>In principle, I am very much in favor of a checker like this.</div><div>Passing an invalid comparison operator is one of the most common misuses of std::sort.</div><div><br></div><div>I worry about the cost, though.</div><div><br></div><div>-- Marshall</div><div><br></div></div></div></div>