This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 03 Jul 2015 10:29:22 +0000
- Subject: [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
- Auto-submitted: auto-generated
- References: <bug-66742-4 at http dot gcc dot gnu dot org/bugzilla/>
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