From eddc0e7d13e8f2f689b560cbcaa73ea95dc2c3cb Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 5 Jan 2015 16:25:32 +0100 Subject: [PATCH] (Possibly) fixed #660 --- libethcore/Exceptions.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libethcore/Exceptions.cpp b/libethcore/Exceptions.cpp index c6f35763e..b0aff4551 100644 --- a/libethcore/Exceptions.cpp +++ b/libethcore/Exceptions.cpp @@ -20,13 +20,22 @@ */ #include "Exceptions.h" +#include #include using namespace std; using namespace dev; using namespace dev::eth; -#define ETH_RETURN_STRING(S) static string s_what; s_what = S; return s_what.c_str(); +#if ALL_COMPILERS_ARE_CPP11_COMPLIANT +#define ETH_RETURN_STRING(S) thread_local static string s_what; s_what = S; return s_what.c_str(); +#else +#define ETH_RETURN_STRING(S) \ + static boost::thread_specific_ptr s_what; \ + if (!s_what.get()) \ + s_what.reset(new string); \ + *s_what = S; return s_what->c_str(); +#endif const char* InvalidBlockFormat::what() const noexcept { ETH_RETURN_STRING("Invalid block format: Bad field " + toString(m_f) + " (" + toHex(m_d) + ")"); } const char* UncleInChain::what() const noexcept { ETH_RETURN_STRING("Uncle in block already mentioned: Uncles " + toString(m_uncles) + " (" + m_block.abridged() + ")"); }