diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-09-11 18:33:45 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-09-11 18:33:45 +0000 |
commit | e9cc5451293b36ef5f0c0d499db5b86c10895208 (patch) | |
tree | 7fb7595e512ce15ffac07cc04d334deab06de3c3 | |
parent | 2533f747d7ed7856fe58f9a02c0c51fdb48a41c6 (diff) | |
download | bcm5719-llvm-e9cc5451293b36ef5f0c0d499db5b86c10895208.tar.gz bcm5719-llvm-e9cc5451293b36ef5f0c0d499db5b86c10895208.zip |
Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping an element with itself
llvm-svn: 341975
-rw-r--r-- | libcxx/include/algorithm | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index ee2a54d7232..55e1f9fc113 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -2987,7 +2987,8 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, for (--__last; __first < __last; ++__first, --__d) { difference_type __i = __rand(__d); - swap(*__first, *(__first + __i)); + if (__i != difference_type(0)) + swap(*__first, *(__first + __i)); } } } |