Skip to content

Commit f5463ac

Browse files
committed
workaround faulty static analysis by clang
Signed-off-by: Ted Lyngmo <[email protected]>
1 parent e758118 commit f5463ac

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include/beman/timed_lock_alg/mutex.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,11 @@ class multi_lock {
232232
if (not m_locked) {
233233
throw std::system_error(std::make_error_code(std::errc::operation_not_permitted));
234234
}
235-
auto unlocker = std::apply([](auto... ms) { return std::scoped_lock(std::adopt_lock, *ms...); }, m_ms);
236-
m_locked = false;
235+
// clang doesn't seem to understand that "unlocker" is actually used to unlock all mutexes at the end of the
236+
// scope even if one of them throws so mark it as maybe_unused.
237+
[[maybe_unused]] auto unlocker =
238+
std::apply([](auto... ms) { return std::scoped_lock(std::adopt_lock, *ms...); }, m_ms);
239+
m_locked = false;
237240
}
238241

239242
// Modifiers

0 commit comments

Comments
 (0)