This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So we need something ugly like this:

--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -398,6 +398,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          }
       }

+#define _GLIBCXX_REPEAT_8(_X) _X, _X, _X, _X, _X, _X, _X, _X
+
   template<typename _Tp, typename _Alloc>
     void
     list<_Tp, _Alloc>::
@@ -407,8 +409,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
          && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
       {
-        list __carry;
-        list __tmp[64];
+        list __carry(get_allocator());
+        list __tmp[64] = {
+           _GLIBCXX_REPEAT_8(_GLIBCXX_REPEAT_8(list(get_allocator())))
+       };
         list * __fill = &__tmp[0];
         list * __counter;

@@ -484,8 +488,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
            && this->_M_impl._M_node._M_next->_M_next !=
&this->_M_impl._M_node)
          {
-           list __carry;
-           list __tmp[64];
+           list __carry(get_allocator());
+           list __tmp[64] = {
+               _GLIBCXX_REPEAT_8(_GLIBCXX_REPEAT_8(list(get_allocator())))
+           };
            list * __fill = &__tmp[0];
            list * __counter;

@@ -511,6 +517,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
            swap(*(__fill - 1));
          }
       }
+#undef _GLIBCXX_REPEAT_8

 _GLIBCXX_END_NAMESPACE_CONTAINER
 } // namespace std


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]