diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2009-08-04 13:01:08 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2009-08-04 13:01:08 +0000 |
commit | 05168714db51c2c2b9456e5370c211314d8332ab (patch) | |
tree | 7809171cc49cbef0c3bf420c0c092104516ee65e /libstdc++-v3 | |
parent | 51b128a0c02995a4fb6c615c92e20d2d969c8528 (diff) | |
download | gcc-05168714db51c2c2b9456e5370c211314d8332ab.zip gcc-05168714db51c2c2b9456e5370c211314d8332ab.tar.gz gcc-05168714db51c2c2b9456e5370c211314d8332ab.tar.bz2 |
re PR libstdc++/15523 ([DR 408] Can't have vectors of vector::const_iterator)
2009-08-04 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/15523
* include/debug/safe_iterator.h (_Safe_iterator<>::
_Safe_iterator(const _Safe_iterator&), _Safe_iterator<>::
operator=(const _Safe_iterator&)): Implement resolution of DR 408,
do not error out when the source is a value-initialized iterator.
* testsuite/23_containers/vector/15523.cc: New.
* doc/xml/manual/intro.xml: Add an entry for DR 408.
From-SVN: r150455
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/doc/xml/manual/intro.xml | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/safe_iterator.h | 20 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/vector/15523.cc | 39 |
4 files changed, 69 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e370098..dafe95f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2009-08-04 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/15523 + * include/debug/safe_iterator.h (_Safe_iterator<>:: + _Safe_iterator(const _Safe_iterator&), _Safe_iterator<>:: + operator=(const _Safe_iterator&)): Implement resolution of DR 408, + do not error out when the source is a value-initialized iterator. + * testsuite/23_containers/vector/15523.cc: New. + * doc/xml/manual/intro.xml: Add an entry for DR 408. + 2009-08-03 Paolo Carlini <paolo.carlini@oracle.com> * include/std/istream (operator>>(basic_istream<>&&, _Tp&)): Minor diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index 560a0b5..2bf4dea 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -604,6 +604,14 @@ requirements of the license of GCC. <listitem><para>Replace "new" with "::new". </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-active.html#408">408</ulink>: + <emphasis> + Is vector<reverse_iterator<char*> > forbidden? + </emphasis> + </term> + <listitem><para>Tweak the debug-mode checks in _Safe_iterator. + </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-defects.html#409">409</ulink>: <emphasis>Closing an fstream should clear the error state</emphasis> </term> diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index dbdb32e..eb0a3e4 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -115,12 +115,14 @@ namespace __gnu_debug /** * @brief Copy construction. - * @pre @p x is not singular */ _Safe_iterator(const _Safe_iterator& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x._M_current) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x._M_current == _Iterator(), _M_message(__msg_init_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -129,8 +131,6 @@ namespace __gnu_debug /** * @brief Converting constructor from a mutable iterator to a * constant iterator. - * - * @pre @p x is not singular */ template<typename _MutableIterator> _Safe_iterator( @@ -140,7 +140,10 @@ namespace __gnu_debug _Sequence>::__type>& __x) : _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base()) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x.base() == _Iterator(), _M_message(__msg_init_const_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -148,12 +151,14 @@ namespace __gnu_debug /** * @brief Copy assignment. - * @pre @p x is not singular */ _Safe_iterator& operator=(const _Safe_iterator& __x) { - _GLIBCXX_DEBUG_VERIFY(!__x._M_singular(), + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // DR 408. Is vector<reverse_iterator<char*> > forbidden? + _GLIBCXX_DEBUG_VERIFY(!__x._M_singular() + || __x._M_current == _Iterator(), _M_message(__msg_copy_singular) ._M_iterator(*this, "this") ._M_iterator(__x, "other")); @@ -169,7 +174,6 @@ namespace __gnu_debug reference operator*() const { - _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); diff --git a/libstdc++-v3/testsuite/23_containers/vector/15523.cc b/libstdc++-v3/testsuite/23_containers/vector/15523.cc new file mode 100644 index 0000000..3b8230c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/15523.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-D_GLIBCXX_DEBUG" } + +#include <vector> + +// libstdc++/15523 +void test01() +{ + using namespace std; + + vector<vector<int>::const_iterator> x(2); + + vector<int>::iterator i2, i3; + vector<int>::const_iterator ci1(i2); + + i2 = i3; +} + +int main() +{ + test01(); + return 0; +} |