commit | e9cc5451293b36ef5f0c0d499db5b86c10895208 | [log] [tgz] |
---|---|---|
author | Marshall Clow <[email protected]> | Tue Sep 11 18:33:45 2018 |
committer | Marshall Clow <[email protected]> | Tue Sep 11 18:33:45 2018 |
tree | 7fb7595e512ce15ffac07cc04d334deab06de3c3 | |
parent | 2533f747d7ed7856fe58f9a02c0c51fdb48a41c6 [diff] [blame] |
Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping an element with itself llvm-svn: 341975
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index ee2a54d..55e1f9f 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm
@@ -2987,7 +2987,8 @@ for (--__last; __first < __last; ++__first, --__d) { difference_type __i = __rand(__d); - swap(*__first, *(__first + __i)); + if (__i != difference_type(0)) + swap(*__first, *(__first + __i)); } } }