Skip to content

Commit

Permalink
run memory leaks tests only with Debug CRT (#2853)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
fsb4000 and StephanTLavavej authored Jul 14, 2022
1 parent 16207c8 commit 96831da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions tests/std/tests/Dev10_908702_string_memory_leak/test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// REQUIRES: debug_CRT

#include <assert.h>
#include <crtdbg.h>
#include <locale>
Expand All @@ -20,9 +22,7 @@ int main() {
v.insert(v.begin(), 2, "2");
}

#ifdef _DEBUG
assert(!_CrtDumpMemoryLeaks());
#endif

{
string one("111");
Expand All @@ -32,21 +32,17 @@ int main() {
two = three;
}

#ifdef _DEBUG
assert(!_CrtDumpMemoryLeaks());
#endif

// Also test DevDiv-846054 "<locale>: Spurious memory leaks".
locale::global(locale(""));

#ifdef _DEBUG
assert(!_CrtDumpMemoryLeaks());
#endif
}

// Also test DevDiv-810608 "<xlocale>: [torino][boost]error C2665:
// 'std::_Crt_new_delete::operator new' : none of the 2 overloads could convert all the argument types".
void meow(void* pv) {
void meow(void* pv) { // COMPILE-ONLY
// Saying "new" instead of "::new" is intentional here.
new (pv) locale();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// REQUIRES: debug_CRT

#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING

#include <assert.h>
Expand Down Expand Up @@ -127,11 +129,9 @@ void test(const int num) {

g_allocations_remaining = 1000000;

#ifdef _DEBUG
if (_CrtDumpMemoryLeaks()) {
abort();
}
#endif

return;
}
Expand Down

0 comments on commit 96831da

Please sign in to comment.