From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 938553858D35 for ; Sun, 5 Jul 2020 21:47:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 938553858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id ED860AD1A; Sun, 5 Jul 2020 21:47:55 +0000 (UTC) Date: Sun, 5 Jul 2020 23:47:54 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [committed][gdb/build,c++17] Fix use of deprecated std::uncaught_exception Message-ID: <20200705214752.GA4063@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jul 2020 21:47:57 -0000 Hi, When compiling gdb with -std=gnu++17, we run into: ... ../../gdb/inferior.h: In member function ‘void \ infcall_suspend_state_deleter::operator()(infcall_suspend_state*) const’: ../../gdb/inferior.h:83:12: error: ‘bool std::uncaught_exception()’ is \ deprecated [-Werror=deprecated-declarations] 83 | if (!std::uncaught_exception ()) ... Fix this by rewriting using std::uncaught_exceptions. Tested on x86_64-linux with gcc 9.3.1 and -std=gnu17/gnu++17. Tested with test-case from RFC patch https://sourceware.org/pipermail/gdb-patches/2020-June/169970.html. Committed to trunk. Thanks, - Tom [gdb/build,c++17] Fix use of deprecated std::uncaught_exception gdb/ChangeLog: 2020-07-05 Tom de Vries PR build/26187 * inferior.h (struct infcall_suspend_state_deleter): If available, use std::uncaught_exceptions instead of deprecated std::uncaught_exception. --- gdb/inferior.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/inferior.h b/gdb/inferior.h index 572c5f3ae7..606cece6c0 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -21,6 +21,8 @@ #if !defined (INFERIOR_H) #define INFERIOR_H 1 +#include + struct target_waitstatus; struct frame_info; struct ui_file; @@ -80,7 +82,13 @@ struct infcall_suspend_state_deleter /* If we are restoring the inferior state due to an exception, some error message will be printed. So, only warn the user when we cannot restore during normal execution. */ - if (!std::uncaught_exception ()) + bool unwinding; +#if __cpp_lib_uncaught_exceptions + unwinding = std::uncaught_exceptions () > 0; +#else + unwinding = std::uncaught_exception (); +#endif + if (!unwinding) warning (_("Failed to restore inferior state: %s"), e.what ()); } }