From patchwork Mon Nov 6 21:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 1860476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=N1JNTI6w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SPPqx4Mb7z1yQL for ; Tue, 7 Nov 2023 08:39:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B03C3858284 for ; Mon, 6 Nov 2023 21:39:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 1E7843858D1E; Mon, 6 Nov 2023 21:38:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E7843858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E7843858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699306734; cv=none; b=qybGcbsLGucXqXsWqaq38sYp/xviXQHPCsrVr5lBfnnR0gbcZy3YGqnuQiYpBMxETP8eIxTX9e/hx6ylGkKpa9F74tLdD4yBEMheLexHMNesHbFBhmY+DoHCfMrkIv4aWHkElscw/7NhJ8e0BVajJsjSbOK1h8pwK4KGSPeG66E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699306734; c=relaxed/simple; bh=7HZBfex99JW0LkWMDGTp5XXUdjCUnqi02tPiI3nIgAM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=CjmEIj0wXMdAW6epMpbNbYYwMcww2l3Hz4UxnyFhSwkv8JXCS8X+hwVK+LjpO4rqJEmG1Em4h7BOs3LasTbk1Tq4QakDh0Zd1A9qE4ksMU4xONmBiSLNv7l+sBJlUnme72lu6/22dmSSLpOoQGleQVhxcmP+470QL/4N259TKgw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40850b244beso37708155e9.2; Mon, 06 Nov 2023 13:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699306731; x=1699911531; darn=gcc.gnu.org; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=o508GSsw1eI4GKk9TItrlP1qE4kl7TzcXCRwdaNXGfo=; b=N1JNTI6wC41TfyOip2cttAk+Z+ZAIBv84BsuCxH22fptmlQ0LLVwbkkA3eiA+HmT0m rme8GgJgwMI7LGLktm4atuLw/RrWg5IcSCwM9vm7WbGcA35JyZxcVsvVTPW1bdGKb4xU 3+4W9vvHOb8yLTSNP4+elooO4qYupTGaJAakH8BPnhrOqxa0eQqP6fLhMhIcVeP14xBg N49KocppMhuGFn1ZAkppE6IlwCun5bT7hkw+8ChVGVrCby4Rdrc7RtwmAayTcGnETxvg Y0TXEpl/MQTyodSWJUpEWj05cntxlZ/xOtGxht+AugXVxswn3Ziz/xw64F7zlBmZphO7 bOug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699306731; x=1699911531; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o508GSsw1eI4GKk9TItrlP1qE4kl7TzcXCRwdaNXGfo=; b=WvyXZL/3POBzBV/OikmxuM2ZtbYBHjFzUd6Un5tpr5Ovbq3LwYVK+HTG7BaIWzt+8T Ab+nmolex1qH4yUqgGBHkNSDXoxd5NbklIAFeDy71cPSabnBQRho/4L7K0IHSHhXlfFs DMgRBUUfC2wtTTJJj7JFJV3zOU3+/tbQwLgmaRsXvgA5/mqllmSUrKCnCZ6mJitwC8Ek xg7ONS593GW8M/08qypYge6EE5TcaVzqlTo1wwpI0k4lUBE0J8LnZGzqWloeBjYyJwE8 efMbvNROgHSldMjvCB0/Ng9L+nxuliIREixo7a/CyYhqozUPV9e1LQvdL4dUTfTRKFfY 972w== X-Gm-Message-State: AOJu0YwQJcMiOf7by+YyVysuNOHn8qAyfNFDOdfLgReMKSNPUvqdaVQX kUHiYCUMkwmm9OLxczadvGQ6zaOO5Pk= X-Google-Smtp-Source: AGHT+IGClHDMPEylvXlmCz6n8LBwvWBCOG2ZD8OGMM/lDMetzimNz6wEYBbFs7ZPZ0O4XUy1qRSrVg== X-Received: by 2002:adf:e401:0:b0:32d:9fc9:d14c with SMTP id g1-20020adfe401000000b0032d9fc9d14cmr27243736wrm.47.1699306730579; Mon, 06 Nov 2023 13:38:50 -0800 (PST) Received: from ?IPV6:2a01:e0a:1dc:b1c0:1e1c:e3b8:17c4:1228? ([2a01:e0a:1dc:b1c0:1e1c:e3b8:17c4:1228]) by smtp.gmail.com with ESMTPSA id l18-20020a5d4bd2000000b0032fb46812c2sm609158wrt.12.2023.11.06.13.38.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Nov 2023 13:38:49 -0800 (PST) Message-ID: <2f5f1761-0108-4900-9926-d49fa03b066c@gmail.com> Date: Mon, 6 Nov 2023 22:38:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: libstdc++ Cc: gcc-patches From: =?utf-8?q?Fran=C3=A7ois_Dumont?= Subject: [PATCH][_Hashtable] Add missing destructor call X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Noticed looking for other occasion to replace __try/__catch with RAII helper.     libstdc++: [_Hashtable] Add missing node destructor call     libstdc++-v3/ChangeLog:             * include/bits/hashtable_policy.h             (_Hashtable_alloc<>::_M_allocate_node): Add missing call to node destructor             on construct exception. Tested under Linux x64, ok to commit ? I hope gmail appli will appreciate .diff instead of .patch. .txt are not in .gitignore so annoying to use for patches. François diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 2d13bda6ae0..ed2b2c02a4a 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -2020,19 +2020,20 @@ namespace __detail _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args) -> __node_ptr { - auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1); + auto& __alloc = _M_node_allocator(); + auto __nptr = __node_alloc_traits::allocate(__alloc, 1); __node_ptr __n = std::__to_address(__nptr); __try { ::new ((void*)__n) __node_type; - __node_alloc_traits::construct(_M_node_allocator(), - __n->_M_valptr(), + __node_alloc_traits::construct(__alloc, __n->_M_valptr(), std::forward<_Args>(__args)...); return __n; } __catch(...) { - __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1); + __n->~__node_type(); + __node_alloc_traits::deallocate(__alloc, __nptr, 1); __throw_exception_again; } }