From f101554e93a2ef004e459d34ef4e19e668302d30 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Wed, 29 Jan 2014 08:07:52 -0800 Subject: [PATCH] fix(util/script_exception): make sure a script_nested_exception may have a nested script_nested_exception, use LEAN_THREAD_LOCAL macro instead of thread_local Signed-off-by: Leonardo de Moura --- src/util/script_exception.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/util/script_exception.cpp b/src/util/script_exception.cpp index 58694aaad..50e46985c 100644 --- a/src/util/script_exception.cpp +++ b/src/util/script_exception.cpp @@ -7,6 +7,7 @@ Author: Leonardo de Moura #include #include #include +#include "util/thread.h" #include "util/debug.h" #include "util/script_exception.h" @@ -70,7 +71,7 @@ char const * script_exception::get_msg() const noexcept { } char const * script_exception::what() const noexcept { - static thread_local std::string buffer; + static LEAN_THREAD_LOCAL std::string buffer; std::ostringstream strm; char const * msg = get_msg(); char const * space = msg && *msg == ' ' ? "" : " "; @@ -92,10 +93,14 @@ script_nested_exception::script_nested_exception(source s, std::string f, unsign script_nested_exception::~script_nested_exception() {} char const * script_nested_exception::what() const noexcept { - static thread_local std::string buffer; - std::ostringstream strm; - strm << script_exception::what() << "\n" << get_exception().what(); - buffer = strm.str(); - return buffer.c_str(); + std::string super_what = script_exception::what(); + std::string nested_what = get_exception().what(); + { + static LEAN_THREAD_LOCAL std::string buffer; + std::ostringstream strm; + strm << super_what << "\n" << nested_what; + buffer = strm.str(); + return buffer.c_str(); + } } }