aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2008-07-15 10:14:40 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2008-07-15 10:14:40 +0000
commit91efdb828d13ca7cafe6aa26d4f208f87dd1e008 (patch)
tree591a0aea7fea486cc6545fc0ddd2554e4416e909 /libstdc++-v3
parentcbcd1e4520ba6e1dbf3b9c44d54a5228846da5c0 (diff)
downloadgcc-91efdb828d13ca7cafe6aa26d4f208f87dd1e008.zip
gcc-91efdb828d13ca7cafe6aa26d4f208f87dd1e008.tar.gz
gcc-91efdb828d13ca7cafe6aa26d4f208f87dd1e008.tar.bz2
re PR libstdc++/36832 (error compiling with crope)
2008-07-15 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/36832 * include/ext/rope (_Destroy_const): Add. (rope<>::copy): Call it. * testsuite/ext/rope/36832.cc: New. From-SVN: r137829
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/ext/rope26
-rw-r--r--libstdc++-v3/testsuite/ext/rope/36832.cc36
3 files changed, 64 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 0aad1ec..e78c7d6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2008-07-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/36832
+ * include/ext/rope (_Destroy_const): Add.
+ (rope<>::copy): Call it.
+ * testsuite/ext/rope/36832.cc: New.
+
2008-07-15 Johannes Singler <singler@ira.uka.de>
* include/parallel/find_selectors.h:
diff --git a/libstdc++-v3/include/ext/rope b/libstdc++-v3/include/ext/rope
index e39761e..b85f98e 100644
--- a/libstdc++-v3/include/ext/rope
+++ b/libstdc++-v3/include/ext/rope
@@ -1,6 +1,6 @@
// SGI's rope class -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -80,6 +80,22 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
using std::allocator;
using std::_Destroy;
+ // See libstdc++/36832.
+ template<typename _ForwardIterator, typename _Allocator>
+ void
+ _Destroy_const(_ForwardIterator __first,
+ _ForwardIterator __last, _Allocator __alloc)
+ {
+ for (; __first != __last; ++__first)
+ __alloc.destroy(&*__first);
+ }
+
+ template<typename _ForwardIterator, typename _Tp>
+ inline void
+ _Destroy_const(_ForwardIterator __first,
+ _ForwardIterator __last, allocator<_Tp>)
+ { _Destroy(__first, __last); }
+
// The _S_eos function is used for those functions that
// convert to/from C-like strings to detect the end of the string.
@@ -1941,11 +1957,11 @@ protected:
this->_M_tree_ptr = _S_balance(this->_M_tree_ptr);
_S_unref(__old);
}
-
+
void
copy(_CharT* __buffer) const
{
- _Destroy(__buffer, __buffer + size(), _M_get_allocator());
+ _Destroy_const(__buffer, __buffer + size(), _M_get_allocator());
_S_flatten(this->_M_tree_ptr, __buffer);
}
@@ -1959,8 +1975,8 @@ protected:
{
size_t __size = size();
size_t __len = (__pos + __n > __size? __size - __pos : __n);
-
- _Destroy(__buffer, __buffer + __len, _M_get_allocator());
+
+ _Destroy_const(__buffer, __buffer + __len, _M_get_allocator());
_S_flatten(this->_M_tree_ptr, __pos, __len, __buffer);
return __len;
}
diff --git a/libstdc++-v3/testsuite/ext/rope/36832.cc b/libstdc++-v3/testsuite/ext/rope/36832.cc
new file mode 100644
index 0000000..93acfa1
--- /dev/null
+++ b/libstdc++-v3/testsuite/ext/rope/36832.cc
@@ -0,0 +1,36 @@
+// Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// rope (SGI extension)
+
+#include <ext/rope>
+
+// libstdc++/36832
+void test01()
+{
+ __gnu_cxx::crope myRope;
+ myRope = "1234567890";
+ char buffer[100];
+ myRope.copy(1, 1, buffer);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}