Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run memory leaks tests only with Debug CRT #2853

Merged
merged 2 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved

#include <algorithm>
#include <assert.h>
#include <chrono>
Expand All @@ -17,11 +19,9 @@
using namespace std;

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

void test_484720();
Expand Down
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