[PATCH] libstdc++: Fix exceptions being generated when compiling with -fno-exceptions

Jonathan Wakely jwakely@redhat.com
Mon Apr 27 21:06:00 GMT 2015


On 14/04/15 12:17 -0300, Federico Lenarduzzi wrote:
>When the libstdc++ is compiled, the compiler sets the std::terminate_handler function with __verbose_terminate_handler() or std::abort() depending on _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE being true or false.
>
>However, even if we compile with -fno-exceptions, the compiler will use __verbose_terminate_handler(), which uses exceptions. Therefore, the library is not fully exception-free.
>
>This patch adds a check for __EXCEPTIONS to the #if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE condition. If __EXCEPTIONS is defined, the compiler will use __verbose_terminate_handler() as a termination function; otherwise it'll use std::abort() which doesn't have exceptions. It also makes std::uncaught_exception() throw() return false if __EXCEPTIONS is not defined.

I've committed this slightly revised version using __cpp_exceptions
instead, and changing the new std::uncaught_exceptions() function too.

Tested x86_64-linux and powerpc64le-linux, and also built with
--enable-libstdcxx-flags=-fno-exceptions on x86_64-linux.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1795 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20150427/8a26cee1/attachment.bin>


More information about the Libstdc++ mailing list