Remove std::construct and std::destroy
Jeffrey Oldham
oldham@codesourcery.com
Tue Jul 3 16:54:00 GMT 2001
On Tue, Jul 03, 2001 at 04:05:00PM -0400, Stephen M. Webb wrote:
> On Tue, 03 Jul 2001, Jeffrey Oldham wrote:
> >
> > This morning, gcc/testsuite/g++.old-deja/g++.robertl/eb130.C failed
> > for my i686-pc-linux-gnu gcc 3.1 build. The problem was caused by a
> > call to an undefined destroy() inside
> > libstdc++-v3/include/ext/stl_hashtable.h's hashtable::_M_delete_node.
> >
> > I modifying its source code using the attached patch which fixed the
> > problem but gcc.c-torture/execute/920730-1t.c then failed. It does
> > not seem that my patch caused the problem.
> >
> > Would you be willing to look at the patch for correctness?
>
> *blush* I missed the extensions entirely. Your patch looks correct but you may
> as well fix ext/stl_rope.h and ext/ropeimpl.h while you're at it, it's just
> simple text substitution.
I am now testing the attached patch, which has changes to
libstdc++-v3/include/ext/{ropeimpl.h,slist,stl_hashtable.h,stl_rope.h}.
I'll check in the patch if everything goes OK.
Thanks,
Jeffrey D. Oldham
oldham@codesourcery.com
? stl_hashtable.h.patch
? construct_destroy.patch
Index: ropeimpl.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/ropeimpl.h,v
retrieving revision 1.5
diff -c -p -r1.5 ropeimpl.h
*** ropeimpl.h 2001/06/27 17:09:53 1.5
--- ropeimpl.h 2001/07/03 23:48:59
*************** inline void _Rope_RopeRep<_CharT,_Alloc>
*** 317,323 ****
_CharT* __cstr = _M_c_string;
if (0 != __cstr) {
size_t __size = _M_size + 1;
! destroy(__cstr, __cstr + __size);
_Data_deallocate(__cstr, __size);
}
}
--- 317,323 ----
_CharT* __cstr = _M_c_string;
if (0 != __cstr) {
size_t __size = _M_size + 1;
! _Destroy(__cstr, __cstr + __size);
_Data_deallocate(__cstr, __size);
}
}
*************** template <class _CharT, class _Alloc>
*** 329,335 ****
allocator_type __a)
{
if (!_S_is_basic_char_type((_CharT*)0)) {
! destroy(__s, __s + __n);
}
// This has to be a static member, so this gets a bit messy
__a.deallocate(
--- 329,335 ----
allocator_type __a)
{
if (!_S_is_basic_char_type((_CharT*)0)) {
! _Destroy(__s, __s + __n);
}
// This has to be a static member, so this gets a bit messy
__a.deallocate(
*************** const _CharT* rope<_CharT,_Alloc>::c_str
*** 1453,1459 ****
// It must have been added in the interim. Hence it had to have been
// separately allocated. Deallocate the old copy, since we just
// replaced it.
! destroy(__old_c_string, __old_c_string + __s + 1);
_Data_deallocate(__old_c_string, __s + 1);
}
# endif
--- 1453,1459 ----
// It must have been added in the interim. Hence it had to have been
// separately allocated. Deallocate the old copy, since we just
// replaced it.
! _Destroy(__old_c_string, __old_c_string + __s + 1);
_Data_deallocate(__old_c_string, __s + 1);
}
# endif
Index: slist
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/slist,v
retrieving revision 1.8
diff -c -p -r1.8 slist
*** slist 2001/06/27 17:09:53 1.8
--- slist 2001/07/03 23:49:00
*************** protected:
*** 265,271 ****
_Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next);
_Slist_node_base* __next_next = __next->_M_next;
__pos->_M_next = __next_next;
! destroy(&__next->_M_data);
_M_put_node(__next);
return __next_next;
}
--- 265,271 ----
_Slist_node<_Tp>* __next = (_Slist_node<_Tp>*) (__pos->_M_next);
_Slist_node_base* __next_next = __next->_M_next;
__pos->_M_next = __next_next;
! _Destroy(&__next->_M_data);
_M_put_node(__next);
return __next_next;
}
*************** _Slist_base<_Tp,_Alloc>::_M_erase_after(
*** 280,286 ****
while (__cur != __last_node) {
_Slist_node<_Tp>* __tmp = __cur;
__cur = (_Slist_node<_Tp>*) __cur->_M_next;
! destroy(&__tmp->_M_data);
_M_put_node(__tmp);
}
__before_first->_M_next = __last_node;
--- 280,286 ----
while (__cur != __last_node) {
_Slist_node<_Tp>* __tmp = __cur;
__cur = (_Slist_node<_Tp>*) __cur->_M_next;
! _Destroy(&__tmp->_M_data);
_M_put_node(__tmp);
}
__before_first->_M_next = __last_node;
*************** private:
*** 318,324 ****
_Node* _M_create_node(const value_type& __x) {
_Node* __node = this->_M_get_node();
__STL_TRY {
! construct(&__node->_M_data, __x);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
--- 318,324 ----
_Node* _M_create_node(const value_type& __x) {
_Node* __node = this->_M_get_node();
__STL_TRY {
! _Construct(&__node->_M_data, __x);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
*************** private:
*** 328,334 ****
_Node* _M_create_node() {
_Node* __node = this->_M_get_node();
__STL_TRY {
! construct(&__node->_M_data);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
--- 328,334 ----
_Node* _M_create_node() {
_Node* __node = this->_M_get_node();
__STL_TRY {
! _Construct(&__node->_M_data);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
*************** public:
*** 425,431 ****
void pop_front() {
_Node* __node = (_Node*) this->_M_head._M_next;
this->_M_head._M_next = __node->_M_next;
! destroy(&__node->_M_data);
this->_M_put_node(__node);
}
--- 425,431 ----
void pop_front() {
_Node* __node = (_Node*) this->_M_head._M_next;
this->_M_head._M_next = __node->_M_next;
! _Destroy(&__node->_M_data);
this->_M_put_node(__node);
}
Index: stl_hashtable.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/stl_hashtable.h,v
retrieving revision 1.7
diff -c -p -r1.7 stl_hashtable.h
*** stl_hashtable.h 2001/06/27 17:09:53 1.7
--- stl_hashtable.h 2001/07/03 23:49:00
*************** private:
*** 517,523 ****
_Node* __n = _M_get_node();
__n->_M_next = 0;
__STL_TRY {
! construct(&__n->_M_val, __obj);
return __n;
}
__STL_UNWIND(_M_put_node(__n));
--- 517,523 ----
_Node* __n = _M_get_node();
__n->_M_next = 0;
__STL_TRY {
! _Construct(&__n->_M_val, __obj);
return __n;
}
__STL_UNWIND(_M_put_node(__n));
*************** private:
*** 525,531 ****
void _M_delete_node(_Node* __n)
{
! destroy(&__n->_M_val);
_M_put_node(__n);
}
--- 525,531 ----
void _M_delete_node(_Node* __n)
{
! _Destroy(&__n->_M_val);
_M_put_node(__n);
}
Index: stl_rope.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/stl_rope.h,v
retrieving revision 1.5
diff -c -p -r1.5 stl_rope.h
*** stl_rope.h 2001/06/27 17:09:53 1.5
--- stl_rope.h 2001/07/03 23:49:01
*************** class rope : public _Rope_base<_CharT,_A
*** 1540,1546 ****
{
_CharT* __buf = _Data_allocate(_S_rounded_up_size(1));
! construct(__buf, __c);
__STL_TRY {
_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);
}
--- 1540,1546 ----
{
_CharT* __buf = _Data_allocate(_S_rounded_up_size(1));
! _Construct(__buf, __c);
__STL_TRY {
_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);
}
*************** class rope : public _Rope_base<_CharT,_A
*** 1642,1648 ****
}
void copy(_CharT* __buffer) const {
! destroy(__buffer, __buffer + size());
_S_flatten(_M_tree_ptr, __buffer);
}
--- 1642,1648 ----
}
void copy(_CharT* __buffer) const {
! _Destroy(__buffer, __buffer + size());
_S_flatten(_M_tree_ptr, __buffer);
}
*************** class rope : public _Rope_base<_CharT,_A
*** 1656,1662 ****
size_t __size = size();
size_t __len = (__pos + __n > __size? __size - __pos : __n);
! destroy(__buffer, __buffer + __len);
_S_flatten(_M_tree_ptr, __pos, __len, __buffer);
return __len;
}
--- 1656,1662 ----
size_t __size = size();
size_t __len = (__pos + __n > __size? __size - __pos : __n);
! _Destroy(__buffer, __buffer + __len);
_S_flatten(_M_tree_ptr, __pos, __len, __buffer);
return __len;
}
More information about the Libstdc++
mailing list