From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15329 invoked by alias); 14 Apr 2015 15:18:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 15219 invoked by uid 89); 14 Apr 2015 15:18:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 14 Apr 2015 15:18:36 +0000 Received: by qkgx75 with SMTP id x75so22411933qkg.1 for ; Tue, 14 Apr 2015 08:18:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=yJUciEWZG0viig9kqiC58wQN0f8taNy8VZPr5D9fxHY=; b=DT70mZt8FYovcRZKnAJDKVcX0LjMyGuoWnG9agATj26YB4SwLX0/4Cb6o6jPNFFP06 FUZ/60QemscV5u8bWqgfpGUITYDAslGrFmuQHIOoQjrYiCJtNwX9+CYZlhnc3K5gw5iU Xfr5QnBPNuOQInUn43YTExKgNoD9dvVmkz1jBgeApX1nUYUfUtI0n2TIs93mQ3SIyKPf p0aI02ZWFlbR9ZNa+9OFBPU/rT2ZhkN42/sjZfqtMEC78bN4GvZtQs201cYWeaJmHr3f 7ZfuC1aREXV7hNXO0yviaarjEbskBzTup86N3kLSIR5xJm3cg5VvfclWlEIqHTMhzrpI zpzQ== X-Gm-Message-State: ALoCoQklmtQLNjQ5YdXZL8xVbwnUYkT9mng1OSfIwADOv1fsEL33aGXHUO9+ugjDfQy3qYzYzUQg X-Received: by 10.140.151.8 with SMTP id 8mr26188454qhx.65.1429024692743; Tue, 14 Apr 2015 08:18:12 -0700 (PDT) Received: from localhost.tallertechnologies.com ([200.69.202.173]) by mx.google.com with ESMTPSA id j190sm900262qhc.33.2015.04.14.08.18.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Apr 2015 08:18:12 -0700 (PDT) From: Federico Lenarduzzi To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix exceptions being generated when compiling with -fno-exceptions Date: Tue, 14 Apr 2015 15:18:00 -0000 Message-Id: <1429024679-17856-1-git-send-email-federico.lenarduzzi@tallertechnologies.com> X-SW-Source: 2015-04/txt/msg00673.txt.bz2 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. libstdc++-v3/ 2015-04-14 Federico Lenarduzzi * libsupc++/eh_catch.cc (std::uncaught_exception() throw()): Add an #else which returns false if __EXCEPTIONS is not defined. * libsupc++/eh_term_handler.cc: Add a check for __EXCEPTIONS to the #if. --- libstdc++-v3/libsupc++/eh_catch.cc | 4 ++++ libstdc++-v3/libsupc++/eh_term_handler.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/libsupc++/eh_catch.cc b/libstdc++-v3/libsupc++/eh_catch.cc index 43e875a..6b500f6 100644 --- a/libstdc++-v3/libsupc++/eh_catch.cc +++ b/libstdc++-v3/libsupc++/eh_catch.cc @@ -136,6 +136,10 @@ __cxxabiv1::__cxa_end_catch () bool std::uncaught_exception() throw() { +#ifdef __EXCEPTIONS __cxa_eh_globals *globals = __cxa_get_globals (); return globals->uncaughtExceptions != 0; +#else + return false; +#endif } diff --git a/libstdc++-v3/libsupc++/eh_term_handler.cc b/libstdc++-v3/libsupc++/eh_term_handler.cc index c855360..0935193 100644 --- a/libstdc++-v3/libsupc++/eh_term_handler.cc +++ b/libstdc++-v3/libsupc++/eh_term_handler.cc @@ -32,7 +32,7 @@ --disable-libstdcxx-verbose and rebuilding the library. In a freestanding environment, we default to this latter approach. */ -#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE +#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE && defined(__EXCEPTIONS) /* The current installed user handler. */ std::terminate_handler __cxxabiv1::__terminate_handler = __gnu_cxx::__verbose_terminate_handler; -- 1.9.3