From: Daniel Arndt Date: Sun, 18 Nov 2018 11:37:07 +0000 (+0100) Subject: Lazily initialize additional_assert_output X-Git-Tag: v9.1.0-rc1~542^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56cc01be98783ff65a443e461388de76dec10d6e;p=dealii.git Lazily initialize additional_assert_output --- 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; }