From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1720) id 3FB5D3858433; Tue, 7 Nov 2023 21:26:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FB5D3858433 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699392415; bh=58vXeg5KGs+xafQtNGu/Ry0PWyTYHpL9bwP1xafolhw=; h=From:To:Subject:Date:From; b=WEDcgIXLuZV0lPW8wgM37CgBnjXFpf5PQRMnDTvn+knw3aiTzvfGpTw+Mgi0z19TC eKLAI4HJRRSz+LAmH2x8lmTenwQ2m7YMncW+aZzrreiFyiKBR+Nl4YAKAIQh5XC+/v NQ6z0npJ0AhGEIN8WyUe9nBUXoTA9aP+XNP2suxw= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Francois Dumont To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-5230] libstdc++: [_Hashtable] Add missing node destructor call X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Git-Refname: refs/heads/master X-Git-Oldrev: d90e5ece367be4648398faabfc06e9c9c0111df1 X-Git-Newrev: 8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84 Message-Id: <20231107212655.3FB5D3858433@sourceware.org> Date: Tue, 7 Nov 2023 21:26:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84 commit r14-5230-g8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84 Author: François Dumont Date: Mon Nov 6 19:34:50 2023 +0100 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. Diff: --- libstdc++-v3/include/bits/hashtable_policy.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 5d162463dc3..a2731b3f63f 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1990,19 +1990,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; } }