Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Mock.cpp
diff options
context:
space:
mode:
authorLeitwolf112026-11-01 19:11:27 +0300
committerLeitwolf112026-11-01 19:11:27 +0300
commit2aea9dafd283d69bec459ea0d495c25d1f6a0f94 (patch)
treee478374100157fe4d0aef16e582dbcabda51e2c1 /src/Progmasoft/Mock.cpp
parentc51d15273e87267215e5877edc268e7db354187b (diff)
downloadcatch3-2aea9dafd283d69bec459ea0d495c25d1f6a0f94.tar.gz
Keep the mock lock alive to the end of the process
A static mutex needs an exit-time destructor, which Clang's warnings refuse, and a mock of static lifetime can outlive it. The test seam is held the same way, and a test covers a mock method with nothing after its parameters, which needs an empty variadic argument to stay valid under -Wpedantic.
Diffstat (limited to 'src/Progmasoft/Mock.cpp')
-rw-r--r--src/Progmasoft/Mock.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Progmasoft/Mock.cpp b/src/Progmasoft/Mock.cpp
index 2897838c..b1364450 100644
--- a/src/Progmasoft/Mock.cpp
+++ b/src/Progmasoft/Mock.cpp
@@ -93,8 +93,9 @@ namespace Progmasoft::Catch3::Detail
std::unique_lock<std::recursive_mutex>
LockMocks()
{
- static std::recursive_mutex mutex;
- return std::unique_lock<std::recursive_mutex>{ mutex };
+ // Never destroyed: a mock of static lifetime can go after it would.
+ static auto *mutex = new std::recursive_mutex;
+ return std::unique_lock<std::recursive_mutex>{ *mutex };
}
void