From 56cc01be98783ff65a443e461388de76dec10d6e Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 18 Nov 2018 12:37:07 +0100 Subject: [PATCH] Lazily initialize additional_assert_output --- source/base/exceptions.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/base/exceptions.cc b/source/base/exceptions.cc index 817bd1cd68..0d17ae45d2 100644 --- a/source/base/exceptions.cc +++ b/source/base/exceptions.cc @@ -43,7 +43,12 @@ namespace deal_II_exceptions { namespace internals { - std::string additional_assert_output; + std::string & + get_additional_assert_output() + { + static std::string additional_assert_output; + return additional_assert_output; + } bool show_stacktrace = true; @@ -51,9 +56,9 @@ namespace deal_II_exceptions } // namespace internals void - set_additional_assert_output(const char *const p) + set_additional_assert_output(const std::string &p) { - internals::additional_assert_output = p; + internals::get_additional_assert_output() = p; } void @@ -324,12 +329,13 @@ ExceptionBase::generate_message() const print_info(converter); print_stack_trace(converter); - if (!deal_II_exceptions::internals::additional_assert_output.empty()) + if (!deal_II_exceptions::internals::get_additional_assert_output() + .empty()) { converter << "--------------------------------------------------------" << std::endl - << deal_II_exceptions::internals::additional_assert_output + << deal_II_exceptions::internals::get_additional_assert_output() << std::endl; } -- 2.39.5