Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84515 - trunk/libs/log/src
From: andrey.semashev_at_[hidden]
Date: 2013-05-26 12:19:54


Author: andysem
Date: 2013-05-26 12:19:53 EDT (Sun, 26 May 2013)
New Revision: 84515
URL: http://svn.boost.org/trac/boost/changeset/84515

Log:
Fall back to portable implementation of unhandled_exception_count() on MinGW GCC 4.4 as it seems to not work the same way as the newer versions of GCC do.
Text files modified:
   trunk/libs/log/src/unhandled_exception_count.cpp | 8 +++++++-
   1 files changed, 7 insertions(+), 1 deletions(-)

Modified: trunk/libs/log/src/unhandled_exception_count.cpp
==============================================================================
--- trunk/libs/log/src/unhandled_exception_count.cpp (original)
+++ trunk/libs/log/src/unhandled_exception_count.cpp 2013-05-26 12:19:53 EDT (Sun, 26 May 2013)
@@ -30,8 +30,13 @@
 BOOST_LOG_ANONYMOUS_NAMESPACE {
 
 #if defined(BOOST_LOG_HAS_CXXABI_H)
+// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As a result, __cxa_get_globals based implementation will always return 0.
+// Just disable it for now and fall back to std::unhandled_exception().
+#if !defined(__MINGW32__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
 // Only GCC 4.7 declares __cxa_get_globals() in cxxabi.h, older compilers do not expose this function but it's there
+#define BOOST_LOG_HAS_CXA_GET_GLOBALS
 extern "C" void* __cxa_get_globals();
+#endif
 #elif defined(_MSC_VER) && _MSC_VER >= 1400
 #define BOOST_LOG_HAS_GETPTD
 extern "C" void* _getptd();
@@ -42,13 +47,14 @@
 //! Returns the number of currently pending exceptions
 BOOST_LOG_API unsigned int unhandled_exception_count() BOOST_NOEXCEPT
 {
-#if defined(BOOST_LOG_HAS_CXXABI_H)
+#if defined(BOOST_LOG_HAS_CXA_GET_GLOBALS)
     // Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64}
     return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(__cxa_get_globals()) + sizeof(void*))); // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8
 #elif defined(BOOST_LOG_HAS_GETPTD)
     // MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}.
     return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(_getptd()) + (sizeof(void*) == 8 ? 0x100 : 0x90))); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
 #else
+ // Portable implementation. Does not allow to detect multiple nested exceptions.
     return static_cast< unsigned int >(std::unhandled_exception());
 #endif
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk