Author: marshall
Date: Tue Sep 11 11:33:45 2018
New Revision: 341975
URL: http://llvm.org/viewvc/llvm-project?rev=341975&view=rev
Log:
Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping
an element with itself
Modified:
libcxx/trunk/include/algorithm
Modified: libcxx/trunk/include/algorithm
URL:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=341975&r1=341974&r2=341975&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Tue Sep 11 11:33:45 2018
@@ -2987,7 +2987,8 @@ random_shuffle(_RandomAccessIterator __f
for (--__last; __first < __last; ++__first, --__d)
{
difference_type __i = __rand(__d);
- swap(*__first, *(__first + __i));
+ if (__i != difference_type(0))
+ swap(*__first, *(__first + __i));
}
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits