Re: [v3] More noexcept for lists

2013-09-18 Thread Paolo Carlini

Hi,

On 09/17/2013 08:44 PM, Marc Glisse wrote:

Hello,

after vectors, lists. I didn't touch the throw we were discussing 
earlier today for now. There will be an inconsistency with debug list 
iterators because they use a general wrapper:
- I would need François to tell if that wrapper is ever used with 
iterators that can throw,
- the same wrapper is used for several containers, so unless we change 
all containers at once it can't stay consistent.
Thus the idea is changing first all the containers and eventually go 
back to __gnu_debug::_Safe_iterator and consistently add the noexcepts 
there? Let's not forget that! (or alternately leave out all the 
iterators related bits for the time being ;)

Bootstrap+testsuite ok.

Patch is otherwise Ok with me, thanks.

Paolo.


Re: [v3] More noexcept for lists

2013-09-18 Thread Marc Glisse

On Wed, 18 Sep 2013, Paolo Carlini wrote:

On 09/17/2013 08:44 PM, Marc Glisse wrote:
after vectors, lists. I didn't touch the throw we were discussing earlier 
today for now. There will be an inconsistency with debug list iterators 
because they use a general wrapper:
- I would need François to tell if that wrapper is ever used with iterators 
that can throw,
- the same wrapper is used for several containers, so unless we change all 
containers at once it can't stay consistent.
Thus the idea is changing first all the containers and eventually go back to 
__gnu_debug::_Safe_iterator and consistently add the noexcepts there?


Yes.

Let's not forget that! (or alternately leave out all the iterators 
related bits for the time being ;)


That would mean one mega-patch doing all the iterators at once :-(


Patch is otherwise Ok with me, thanks.


Ok, I'll commit it now and move to other containers.

--
Marc Glisse


[v3] More noexcept for lists

2013-09-17 Thread Marc Glisse

Hello,

after vectors, lists. I didn't touch the throw we were discussing earlier 
today for now. There will be an inconsistency with debug list iterators 
because they use a general wrapper:
- I would need François to tell if that wrapper is ever used with 
iterators that can throw,
- the same wrapper is used for several containers, so unless we change all 
containers at once it can't stay consistent.


Bootstrap+testsuite ok.

2013-09-18  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/58338
* include/bits/list.tcc (_List_base::_M_clear, list::erase): Mark as
noexcept.
* include/bits/stl_list.h (_List_iterator) [_List_iterator,
_M_const_cast, operator*, operator-, operator++, operator--,
operator==, operator!=]: Likewise.
(_List_const_iterator) [_List_const_iterator, _M_const_cast, operator*,
operator-, operator++, operator--, operator==, operator!=]: Likewise.
(operator==(const _List_iterator, const _List_const_iterator),
operator!=(const _List_iterator, const _List_const_iterator)):
Likewise.
(_List_impl) [_List_impl(const _Node_alloc_type),
_List_impl(_Node_alloc_type)]: Likewise.
(_List_base) [_M_put_node, _List_base(const _Node_alloc_type),
_List_base(_List_base), _M_clear, _M_init]: Likewise.
(list) [list(), list(const allocator_type)]: Merge.
(list) [list(const allocator_type), front, back, pop_front, pop_back,
erase, _M_erase]: Mark as noexcept.
* include/debug/list (list) [list(const _Allocator), front, back,
pop_front, pop_back, _M_erase, erase]: Likewise.
* include/profile/list (list) [list(const _Allocator), front, back,
pop_front, pop_back, erase]: Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.

--
Marc GlisseIndex: include/bits/list.tcc
===
--- include/bits/list.tcc   (revision 202655)
+++ include/bits/list.tcc   (working copy)
@@ -56,21 +56,21 @@
 #ifndef _LIST_TCC
 #define _LIST_TCC 1
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   templatetypename _Tp, typename _Alloc
 void
 _List_base_Tp, _Alloc::
-_M_clear()
+_M_clear() _GLIBCXX_NOEXCEPT
 {
   typedef _List_node_Tp  _Node;
   _Node* __cur = static_cast_Node*(_M_impl._M_node._M_next);
   while (__cur != _M_impl._M_node)
{
  _Node* __tmp = __cur;
  __cur = static_cast_Node*(__cur-_M_next);
 #if __cplusplus = 201103L
  _M_get_Node_allocator().destroy(__tmp);
 #else
@@ -138,21 +138,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __it;
  }
return __position._M_const_cast();
   }
 #endif
 
   templatetypename _Tp, typename _Alloc
 typename list_Tp, _Alloc::iterator
 list_Tp, _Alloc::
 #if __cplusplus = 201103L
-erase(const_iterator __position)
+erase(const_iterator __position) noexcept
 #else
 erase(iterator __position)
 #endif
 {
   iterator __ret = iterator(__position._M_node-_M_next);
   _M_erase(__position._M_const_cast());
   return __ret;
 }
 
 #if __cplusplus = 201103L
Index: include/bits/stl_list.h
===
--- include/bits/stl_list.h (revision 202655)
+++ include/bits/stl_list.h (working copy)
@@ -126,76 +126,76 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 {
   typedef _List_iterator_Tp_Self;
   typedef _List_node_Tp_Node;
 
   typedef ptrdiff_t  difference_type;
   typedef std::bidirectional_iterator_tagiterator_category;
   typedef _Tpvalue_type;
   typedef _Tp*   pointer;
   typedef _Tp   reference;
 
-  _List_iterator()
+  _List_iterator() _GLIBCXX_NOEXCEPT
   : _M_node() { }
 
   explicit
-  _List_iterator(__detail::_List_node_base* __x)
+  _List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT
   : _M_node(__x) { }
 
   _Self
-  _M_const_cast() const
+  _M_const_cast() const _GLIBCXX_NOEXCEPT
   { return *this; }
 
   // Must downcast from _List_node_base to _List_node to get to _M_data.
   reference
-  operator*() const
+  operator*() const _GLIBCXX_NOEXCEPT
   { return static_cast_Node*(_M_node)-_M_data; }
 
   pointer
-  operator-() const
+  operator-() const _GLIBCXX_NOEXCEPT
   { return