diff options
| author | Leitwolf11 | 2026-11-01 19:11:27 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-01 19:11:27 +0300 |
| commit | 2aea9dafd283d69bec459ea0d495c25d1f6a0f94 (patch) | |
| tree | e478374100157fe4d0aef16e582dbcabda51e2c1 /src/Progmasoft/Mock.cpp | |
| parent | c51d15273e87267215e5877edc268e7db354187b (diff) | |
| download | catch3-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.cpp | 5 |
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 |