From b8f5856171df54e83180b09c5aae9407c55e117f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 Oct 2014 12:56:42 +0000 Subject: [PATCH] Work around unavailability of std::exception_ptr with some g++ versions. g++ headers only provide std::exception_ptr when __GCC_ATOMIC_INT_LOCK_FREE is 2, indicating that atomic operations on int are available, so check for this before setting HAS_EXCEPTION_PTR as in some MinGW builds (TDM gcc 4.7) this symbol is not defined as 2. Closes #16634. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/appbase.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index b5852d45ee..d4374e7fd4 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -51,8 +51,23 @@ // Do we have a C++ compiler with enough C++11 support for // std::exception_ptr and functions working with it? #if __cplusplus >= 201103L - // Any conforming C++11 compiler should have it. - #define HAS_EXCEPTION_PTR + // Any conforming C++11 compiler should have it, but g++ implementation + // of exception handling depends on the availability of the atomic int + // operations apparently, so all known version of g++ with C++11 support + // (4.7..4.9) fail to provide exception_ptr if the symbol below is not + // set to 2 (meaning "always available"), which is notably the case for + // MinGW-w64 without -march=486 switch, see #16634. + #ifdef __GNUC__ + // This symbol is always defined in the known g++ version, so + // assume that if it isn't defined, things changed for the better + // and optimistically suppose that exception_ptr is available. + #if !defined(__GCC_ATOMIC_INT_LOCK_FREE) \ + || __GCC_ATOMIC_INT_LOCK_FREE > 1 + #define HAS_EXCEPTION_PTR + #endif + #else + #define HAS_EXCEPTION_PTR + #endif #elif wxCHECK_VISUALC_VERSION(11) // VC++ supports it since version 10, even though it doesn't define // __cplusplus to C++11 value, but MSVC 2010 doesn't have a way to test