blob: b3bec4801f2890d5f400852bc5caaac330651623 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
From 45d7978dafceca8200fa4434d762f62642dc7cb4 Mon Sep 17 00:00:00 2001
From: Sergiu Deitsch <sergiud@users.noreply.github.com>
Date: Tue, 2 Jan 2024 13:01:42 +0100
Subject: [PATCH] fix(tests): prevent clang from optimizing new away (#1017)
---
src/logging_unittest.cc | 13 +++++++++++--
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc
index cb1c657e7..40da9a44d 100644
--- a/src/logging_unittest.cc
+++ b/src/logging_unittest.cc
@@ -355,12 +355,19 @@ struct NewHook {
}
};
+namespace {
+int* allocInt() { return new int; }
+} // namespace
+
TEST(DeathNoAllocNewHook, logging) {
// tests that NewHook used below works
NewHook new_hook;
- ASSERT_DEATH({
- new int;
- }, "unexpected new");
+ // Avoid unused warnings under MinGW
+ //
+ // NOTE MSVC produces warning C4551 here if we do not take the address of the
+ // function explicitly.
+ (void)&allocInt;
+ ASSERT_DEATH({ allocInt(); }, "unexpected new");
}
void TestRawLogging() {
|