From patchwork Tue Aug 27 14:00:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 96564 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3096385F027 for ; Tue, 27 Aug 2024 14:01:06 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id B26E6385DDCA for ; Tue, 27 Aug 2024 13:59:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B26E6385DDCA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B26E6385DDCA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767160; cv=none; b=HP7Di3X1dda4FNlYbUIXsN0YsjFjd1CYMP1iNrbT/usO6z3JrTjTNCr8rGPzoMsu+t+CSsBVnAKmZsasOlLWRiqHzin0IYdiXA6BBXlm9p7jGrbujFNJWv5FaHd1klBoYzrSfB+BX3076sIICB3pcHQJI0maakBjTo7lYh1Z7N0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724767160; c=relaxed/simple; bh=srz5DY6UGG6efaa+UWOJ1tgC8LPyRDPGaYfU7qUp7pQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=DFzVuharPKAV91WgDydc7T2CR4a0YSaCeNDnhUjR3hHDjfVKzWQEJRjvc+XGeANsGpgl1UfhhX0ecI5AfOh/a21DBt+EIq0zGzu7zCJoHvC+yH499plvqhGTYDQlOgNIjHSv6qTL59zCkZ1UAKSTcUrcbw0da64Rw1PAt+XSN3w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 880DA21B15 for ; Tue, 27 Aug 2024 13:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724767155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbzRkz9EGx3UK0BGZF2qt0MIlc2OFK8wH8nANDgI4k4=; b=yBTChcFYaXnYPbsF5iJQDuDnkjHWZDg+q+oQsWnuKjTnFuj6hiBNFIEtBqxBTool1CDgpD JhgAmudLriIZNZQ8xHOtel/wixb9HrsNpJGaARCQgpSVj2Gal3Z6uEqpslv5fnkKkQjB1C x/+8IJTtyuis0A3sdKVlrs3sWgLceJQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724767155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbzRkz9EGx3UK0BGZF2qt0MIlc2OFK8wH8nANDgI4k4=; b=R5xODAOPVTMdm7vFdknL1fuIYSq+3i0rdItpg5kGCcE+74TsqbgV6dToL0Eh6x4PRSmAcG YPXsnlLonn6O4VBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yBTChcFY; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=R5xODAOP DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724767155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbzRkz9EGx3UK0BGZF2qt0MIlc2OFK8wH8nANDgI4k4=; b=yBTChcFYaXnYPbsF5iJQDuDnkjHWZDg+q+oQsWnuKjTnFuj6hiBNFIEtBqxBTool1CDgpD JhgAmudLriIZNZQ8xHOtel/wixb9HrsNpJGaARCQgpSVj2Gal3Z6uEqpslv5fnkKkQjB1C x/+8IJTtyuis0A3sdKVlrs3sWgLceJQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724767155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbzRkz9EGx3UK0BGZF2qt0MIlc2OFK8wH8nANDgI4k4=; b=R5xODAOPVTMdm7vFdknL1fuIYSq+3i0rdItpg5kGCcE+74TsqbgV6dToL0Eh6x4PRSmAcG YPXsnlLonn6O4VBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7191B13A94 for ; Tue, 27 Aug 2024 13:59:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AAxcGrPbzWbvBgAAD6G6ig (envelope-from ) for ; Tue, 27 Aug 2024 13:59:15 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 2/7] [gdb] Make scope_exit constructor throw Date: Tue, 27 Aug 2024 16:00:16 +0200 Message-Id: <20240827140021.32660-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240827140021.32660-1-tdevries@suse.de> References: <20240827140021.32660-1-tdevries@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 880DA21B15 X-Spam-Level: X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, suse.de:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -5.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org While reviewing "catch (...)" uses I came across: ... scope_exit (EFP &&f) try : m_exit_function ((!std::is_lvalue_reference::value && std::is_nothrow_constructible::value) ? std::move (f) : f) { } catch (...) { /* "If the initialization of exit_function throws an exception, calls f()." */ f (); } ... and while looking up the origin of the comment here [1] I saw right after: ... throws: Nothing, unless the initialization of exit_function throws ... I think that means that the exception should be rethrown, so fix this by doing so. Tested on aarch64-linux. [1] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0052r5.pdf --- gdbsupport/scope-exit.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdbsupport/scope-exit.h b/gdbsupport/scope-exit.h index 86b2969f817..2871a59c002 100644 --- a/gdbsupport/scope-exit.h +++ b/gdbsupport/scope-exit.h @@ -109,6 +109,9 @@ class scope_exit : public scope_exit_base> /* "If the initialization of exit_function throws an exception, calls f()." */ f (); + /* "throws: Nothing, unless the initialization of exit_function + throws." */ + throw; } template