PR libstdc++/87872 Avoids iterator transfer on self splice

Message ID 33df4aa8-af31-fc03-6864-dd5e3e1e6b7b@gmail.com
State New
Headers show
Series
  • PR libstdc++/87872 Avoids iterator transfer on self splice
Related show

Commit Message

François Dumont Nov. 6, 2018, 9:49 a.m.
Here is the patch submitted by John and now fully tested.

     PR libstdc++/87872
     * include/debug/safe_sequence.tcc
     (_Safe_sequence<>::_M_transfer_from_if): Skip transfer to self.

Is it fine to commit it now ?

François

Comments

Jonathan Wakely Nov. 6, 2018, 6:16 p.m. | #1
On 06/11/18 10:49 +0100, François Dumont wrote:
>Here is the patch submitted by John and now fully tested.

>

>    PR libstdc++/87872

>    * include/debug/safe_sequence.tcc

>    (_Safe_sequence<>::_M_transfer_from_if): Skip transfer to self.

>

>Is it fine to commit it now ?


OK, thanks.


>François

>


>diff --git a/libstdc++-v3/include/debug/safe_sequence.tcc b/libstdc++-v3/include/debug/safe_sequence.tcc

>index 12de48cf322..ce9a807e79f 100644

>--- a/libstdc++-v3/include/debug/safe_sequence.tcc

>+++ b/libstdc++-v3/include/debug/safe_sequence.tcc

>@@ -68,6 +68,9 @@ namespace __gnu_debug

>       _Safe_sequence<_Sequence>::

>       _M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred)

>       {

>+	if (this == std::__addressof(__from))

>+	  return;

>+

> 	typedef typename _Sequence::iterator iterator;

> 	typedef typename _Sequence::const_iterator const_iterator;

>

Patch

diff --git a/libstdc++-v3/include/debug/safe_sequence.tcc b/libstdc++-v3/include/debug/safe_sequence.tcc
index 12de48cf322..ce9a807e79f 100644
--- a/libstdc++-v3/include/debug/safe_sequence.tcc
+++ b/libstdc++-v3/include/debug/safe_sequence.tcc
@@ -68,6 +68,9 @@  namespace __gnu_debug
       _Safe_sequence<_Sequence>::
       _M_transfer_from_if(_Safe_sequence& __from, _Predicate __pred)
       {
+	if (this == std::__addressof(__from))
+	  return;
+
 	typedef typename _Sequence::iterator iterator;
 	typedef typename _Sequence::const_iterator const_iterator;