mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 18:38:30 +08:00
Add array bounds assertions to satisfy MSVC's /analyze flag. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@273820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,13 +22,17 @@ void
|
||||
test_larger_sorts(unsigned N, unsigned M)
|
||||
{
|
||||
assert(N != 0);
|
||||
assert(N >= M);
|
||||
int* array = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
array[i] = i;
|
||||
std::random_shuffle(array, array+N);
|
||||
std::partial_sort(array, array+M, array+N);
|
||||
for (int i = 0; i < M; ++i)
|
||||
{
|
||||
assert(i < N); // quiet analysis warnings
|
||||
assert(array[i] == i);
|
||||
}
|
||||
delete [] array;
|
||||
}
|
||||
|
||||
|
@@ -35,13 +35,17 @@ void
|
||||
test_larger_sorts(unsigned N, unsigned M)
|
||||
{
|
||||
assert(N != 0);
|
||||
assert(N >= M);
|
||||
int* array = new int[N];
|
||||
for (int i = 0; i < N; ++i)
|
||||
array[i] = i;
|
||||
std::random_shuffle(array, array+N);
|
||||
std::partial_sort(array, array+M, array+N, std::greater<int>());
|
||||
for (int i = 0; i < M; ++i)
|
||||
{
|
||||
assert(i < N); // quiet analysis warnings
|
||||
assert(array[i] == N-i-1);
|
||||
}
|
||||
delete [] array;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user