public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][_Hashtable] Add missing destructor call
@ 2023-11-06 21:38 François Dumont
  2023-11-06 21:58 ` Sam James
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: François Dumont @ 2023-11-06 21:38 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

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

[-- Attachment #2: hashtable_policy.h.diff --]
[-- Type: text/x-patch, Size: 1097 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_Hashtable] Add missing destructor call
  2023-11-06 21:38 [PATCH][_Hashtable] Add missing destructor call François Dumont
@ 2023-11-06 21:58 ` Sam James
  2023-11-06 23:13 ` Jonathan Wakely
  2023-11-06 23:28 ` Jonathan Wakely
  2 siblings, 0 replies; 6+ messages in thread
From: Sam James @ 2023-11-06 21:58 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_Hashtable] Add missing destructor call
  2023-11-06 21:38 [PATCH][_Hashtable] Add missing destructor call François Dumont
  2023-11-06 21:58 ` Sam James
@ 2023-11-06 23:13 ` Jonathan Wakely
  2023-11-06 23:28 ` Jonathan Wakely
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2023-11-06 23:13 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_Hashtable] Add missing destructor call
  2023-11-06 21:38 [PATCH][_Hashtable] Add missing destructor call François Dumont
  2023-11-06 21:58 ` Sam James
  2023-11-06 23:13 ` Jonathan Wakely
@ 2023-11-06 23:28 ` Jonathan Wakely
  2023-11-08  5:39   ` François Dumont
  2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2023-11-06 23:28 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_Hashtable] Add missing destructor call
  2023-11-06 23:28 ` Jonathan Wakely
@ 2023-11-08  5:39   ` François Dumont
  2023-11-08 14:26     ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: François Dumont @ 2023-11-08  5:39 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches


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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][_Hashtable] Add missing destructor call
  2023-11-08  5:39   ` François Dumont
@ 2023-11-08 14:26     ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2023-11-08 14:26 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-08 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-06 21:38 [PATCH][_Hashtable] Add missing destructor call François Dumont
2023-11-06 21:58 ` Sam James
2023-11-06 23:13 ` Jonathan Wakely
2023-11-06 23:28 ` Jonathan Wakely
2023-11-08  5:39   ` François Dumont
2023-11-08 14:26     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).