From patchwork Tue Apr 14 15:17:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Lenarduzzi X-Patchwork-Id: 461171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E63EE140134 for ; Wed, 15 Apr 2015 01:19:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=S9QpQq4D; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; q=dns; s=default; b=OACByG0cHBYhidE 5Ced1mAky/2yM3ngtfaKoS1wmZpuufJiwfAUxMXPPT5iQf5vQMc15PPqVyJQu8Fe hQitMp7pzKM3C8hTA06l5z4xBFdy9hZGAVYMeFvaLKI5RCEfVFXHAnB8stQ7dHsu hHtF917+VwcScC6JBIOZ8kzX+MEo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; s=default; bh=5EtH8fw/5Cfwz292+Uh+0 6DCmzs=; b=S9QpQq4DD7GNzlef4QR4bs/ZGD/2G8ATkyzCSgTvVXVJT4JOendpp 1/jwAjXFwZ6nvepDPuNJhAvxxx62dsoGu+MYhq8tbsPDUeD0r20FnLgnJjy2SXM9 ol9/P0IMNoIei8xO9o7ZWuSrhtd6CMZ7ITtB84b0iia370UAwSv7tM= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 12:17:59 -0300 Message-Id: <1429024679-17856-1-git-send-email-federico.lenarduzzi@tallertechnologies.com> 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;