diff options
| author | Leitwolf11 | 2026-11-14 00:56:32 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-14 00:56:32 +0300 |
| commit | 5ad02bccfcb925df02d1273901b6e248d477c5fa (patch) | |
| tree | e8db06877788de36d3fd4166472c4511f0c0412a | |
| parent | 826735e00bfac9967a7979eae5a42cb49eac851b (diff) | |
| download | catch3-5ad02bccfcb925df02d1273901b6e248d477c5fa.tar.gz | |
Make the start lock a never-destroyed objectfeature/per-test-coverage
A function-local static std::mutex has an exit-time destructor, which
the macOS build rejects with -Wexit-time-destructors. The lock is now
allocated once and never destroyed, which also keeps it usable by a
thread that starts a child while the process exits.
| -rw-r--r-- | extras/catch_amalgamated.cpp | 6 | ||||
| -rw-r--r-- | src/Progmasoft/Runner/Process.cpp | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index 7a1c9541..4b928849 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -16292,8 +16292,10 @@ namespace Progmasoft::Catch3::Runner std::mutex & StartLock() { - static std::mutex lock; - return lock; + // Never destroyed, so no exit-time destructor runs while a + // detached thread may still start a child. + static std::mutex *const lock = new std::mutex; + return *lock; } } // namespace diff --git a/src/Progmasoft/Runner/Process.cpp b/src/Progmasoft/Runner/Process.cpp index 41fa87f1..e3b0997b 100644 --- a/src/Progmasoft/Runner/Process.cpp +++ b/src/Progmasoft/Runner/Process.cpp @@ -621,8 +621,10 @@ namespace Progmasoft::Catch3::Runner std::mutex & StartLock() { - static std::mutex lock; - return lock; + // Never destroyed, so no exit-time destructor runs while a + // detached thread may still start a child. + static std::mutex *const lock = new std::mutex; + return *lock; } } // namespace |