aboutsummaryrefslogtreecommitdiff
path: root/butl/diagnostics.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-13 16:39:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-13 16:39:58 +0200
commita4199b808fd678f74935d540490eae9dc78a9ffe (patch)
tree16d1f0e583c926838b92722e000fae2c1ac4aa9e /butl/diagnostics.cxx
parentb05e24a7f512c1f005dbcb67b3fce8b3d16e110e (diff)
Fix thread safety issue
Diffstat (limited to 'butl/diagnostics.cxx')
-rw-r--r--butl/diagnostics.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/butl/diagnostics.cxx b/butl/diagnostics.cxx
index e4c22dc..ad84810 100644
--- a/butl/diagnostics.cxx
+++ b/butl/diagnostics.cxx
@@ -28,14 +28,19 @@ namespace butl
diag_record::
~diag_record () noexcept (false)
{
- // Don't flush the record if this destructor was called as part of
- // the stack unwinding. Right now this means we cannot use this
- // mechanism in destructors, which is not a big deal, except for
- // one place: exception_guard. So for now we are going to have
- // this ugly special check which we will be able to get rid of
- // once C++17 uncaught_exceptions() becomes available.
+ // Don't flush the record if this destructor was called as part of the
+ // stack unwinding.
+ //
+#ifdef BUTL_CXX17_UNCAUGHT_EXCEPTIONS
+ if (uncaught_ == std::uncaught_exceptions ())
+ flush ();
+#else
+ // Fallback implementation. Right now this means we cannot use this
+ // mechanism in destructors, which is not a big deal, except for one
+ // place: exception_guard. Thus the ugly special check.
//
if (!std::uncaught_exception () || exception_unwinding_dtor)
flush ();
+#endif
}
}