diff mbox series

[_Hashtable] Add missing destructor call

Message ID 2f5f1761-0108-4900-9926-d49fa03b066c@gmail.com
State New
Headers show
Series [_Hashtable] Add missing destructor call | expand

Commit Message

François Dumont Nov. 6, 2023, 9:38 p.m. UTC
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

Comments

Sam James Nov. 6, 2023, 9:58 p.m. UTC | #1
François Dumont <frs.dumont@gmail.com> writes:

> 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.

Are you using 'git send-email'? It should handle all of that for you.

>
> François
>
> [2. text/x-patch; hashtable_policy.h.diff]...
Jonathan Wakely Nov. 6, 2023, 11:13 p.m. UTC | #2
On Mon, 6 Nov 2023 at 21:39, François Dumont <frs.dumont@gmail.com> wrote:
>
> 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.

No, it doesn't.

> .txt are not
> in .gitignore so annoying to use for patches.

You don't have to create the file inside the Git repo, e.g. I dump
patches to /tmp/patch.txt
Jonathan Wakely Nov. 6, 2023, 11:28 p.m. UTC | #3
On Mon, 6 Nov 2023 at 21:39, François Dumont <frs.dumont@gmail.com> wrote:
>
> 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 ?

OK.

Is this missing on any branches too?
I don't think it's actually a problem, since it's a trivial destructor anyway.


>
> I hope gmail appli will appreciate .diff instead of .patch. .txt are not
> in .gitignore so annoying to use for patches.
>
> François
François Dumont Nov. 8, 2023, 5:39 a.m. UTC | #4
On 07/11/2023 00:28, Jonathan Wakely wrote:
> On Mon, 6 Nov 2023 at 21:39, François Dumont <frs.dumont@gmail.com> wrote:
>> 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 ?
> OK.
>
> Is this missing on any branches too?
Clearly all maintained branches.
> I don't think it's actually a problem, since it's a trivial destructor anyway.

Yes, me neither, I was only thinking about sanity checker tools when 
doing this so no plan for backports.
Jonathan Wakely Nov. 8, 2023, 2:26 p.m. UTC | #5
On Wed, 8 Nov 2023 at 05:39, François Dumont <frs.dumont@gmail.com> wrote:
>
>
> On 07/11/2023 00:28, Jonathan Wakely wrote:
> > On Mon, 6 Nov 2023 at 21:39, François Dumont <frs.dumont@gmail.com> wrote:
> >> 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 ?
> > OK.
> >
> > Is this missing on any branches too?
> Clearly all maintained branches.
> > I don't think it's actually a problem, since it's a trivial destructor anyway.
>
> Yes, me neither, I was only thinking about sanity checker tools when
> doing this so no plan for backports.

OK, that seems fine, thanks.
diff mbox series

Patch

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;
 	  }
       }