diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c4f2fe8ad5db33eb19fa0c442f80324fa3f9c2d3..48059ebe044bb1cd83c283896c6dbef7a19b6ff0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,40 @@ +2006-09-20 Paolo Carlini <pcarlini@suse.de> + + PR libstdc++/29134 + * include/bits/stl_list.h (list<>::max_size): Forward to allocator' + max_size. + * include/bits/stl_vector.h (vector<>::max_size): Likewise. + * include/bits/stl_deque.h (deque<>::max_size): Likewise. + * include/bits/stl_tree.h (_Rb_tree<>::max_size): Likewise. + * include/tr1/hashtable (_Hashtable<>::max_size): Likewise. + * testsuite/23_containers/vector/capacity/29134.cc: Add. + * testsuite/23_containers/deque/capacity/29134.cc: Likewise. + * testsuite/23_containers/list/capacity/29134.cc: Likewise. + * testsuite/23_containers/set/capacity/29134.cc: Likewise. + * testsuite/23_containers/map/capacity/29134.cc: Likewise. + * testsuite/23_containers/multiset/capacity/29134.cc: Likewise. + * testsuite/23_containers/multimap/capacity/29134.cc: Likewise. + * testsuite/tr1/6_containers/unordered/capacity/29134-set.cc: Likewise. + * testsuite/tr1/6_containers/unordered/capacity/29134-map.cc: Likewise. + * testsuite/tr1/6_containers/unordered/capacity/29134-multiset.cc: + Likewise. + * testsuite/tr1/6_containers/unordered/capacity/29134-multimap.cc: + Likewise. + + * include/bits/deque.tcc (deque<>::_M_new_elements_at_front, + deque<>::_M_new_elements_at_back): Check for length errors. + * testsuite/23_containers/deque/capacity/29134-2.cc: New. + * testsuite/23_containers/vector/capacity/29134-2.cc: Likewise. + + * include/tr1/hashtable (_Hashtable<>::_M_get_Value_allocator): Add. + (_Hashtable<>::_M_allocate_node, _M_deallocate_node): Use it. + * testsuite/tr1/6_containers/unordered/instantiate/set.cc: Add test. + * testsuite/tr1/6_containers/unordered/instantiate/map.cc: Likewise. + * testsuite/tr1/6_containers/unordered/instantiate/multiset.cc: + Likewise. + * testsuite/tr1/6_containers/unordered/instantiate/multimap.cc: + Likewise. + 2006-09-20 Benjamin Kosnik <bkoz@redhat.com> * include/ext/pb_ds/detail/ diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 8740101a299389d8b7d6024a3c4aea6c36fa3395..4416b71c948bae010f4b6a1c28addb2fee4ad9fb 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -1,6 +1,7 @@ // Deque implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 +// 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 @@ -277,13 +278,13 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) for (__cur_node = this->_M_impl._M_start._M_node; __cur_node < this->_M_impl._M_finish._M_node; ++__cur_node) - { - _ForwardIterator __mid = __first; - std::advance(__mid, _S_buffer_size()); - std::__uninitialized_copy_a(__first, __mid, *__cur_node, - _M_get_Tp_allocator()); - __first = __mid; - } + { + _ForwardIterator __mid = __first; + std::advance(__mid, _S_buffer_size()); + std::__uninitialized_copy_a(__first, __mid, *__cur_node, + _M_get_Tp_allocator()); + __first = __mid; + } std::__uninitialized_copy_a(__first, __last, this->_M_impl._M_finish._M_first, _M_get_Tp_allocator()); @@ -659,8 +660,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) deque<_Tp, _Alloc>:: _M_new_elements_at_front(size_type __new_elems) { - const size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_front")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); _M_reserve_map_at_front(__new_nodes); size_type __i; try @@ -681,8 +685,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) deque<_Tp, _Alloc>:: _M_new_elements_at_back(size_type __new_elems) { - const size_type __new_nodes - = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); + if (this->max_size() - this->size() < __new_elems) + __throw_length_error(__N("deque::_M_new_elements_at_back")); + + const size_type __new_nodes = ((__new_elems + _S_buffer_size() - 1) + / _S_buffer_size()); _M_reserve_map_at_back(__new_nodes); size_type __i; try @@ -715,8 +722,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) + (__add_at_front ? __nodes_to_add : 0); if (__new_nstart < this->_M_impl._M_start._M_node) std::copy(this->_M_impl._M_start._M_node, - this->_M_impl._M_finish._M_node + 1, - __new_nstart); + this->_M_impl._M_finish._M_node + 1, + __new_nstart); else std::copy_backward(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1, diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index ffa58744f991f49c182799808d0bf6c83c5c9c4b..03cda6956ca2ad4a6d2d246f94eb4f08204d254e 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -870,7 +870,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** Returns the size() of the largest possible %deque. */ size_type max_size() const - { return size_type(-1); } + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %deque to the specified number of elements. @@ -1521,7 +1521,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) } void - _M_reserve_map_at_front (size_type __nodes_to_add = 1) + _M_reserve_map_at_front(size_type __nodes_to_add = 1) { if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node - this->_M_impl._M_map)) diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 5ae400f6f0f47bcaa706f37390ab827bc2271576..e37e5ee36f3b1fe38d4bd637c6312ab6711d5f8a 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -662,7 +662,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** Returns the size() of the largest possible %list. */ size_type max_size() const - { return size_type(-1); } + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %list to the specified number of elements. diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index ecea171c457c060b678c56b2de2b5eeb3fe3131a..e1efe0a6d2cb29dcb1009e5b4f3103f47533cf35 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -650,7 +650,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) size_type max_size() const - { return size_type(-1); } + { return get_allocator().max_size(); } void swap(_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __t); diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index b4434fca8631d2d342b44d57e2e49487f023a271..a81c5974d997f5729a7175ecd75480b837d86e19 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -399,7 +399,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) /** Returns the size() of the largest possible %vector. */ size_type max_size() const - { return size_type(-1) / sizeof(value_type); } + { return _M_get_Tp_allocator().max_size(); } /** * @brief Resizes the %vector to the specified number of elements. diff --git a/libstdc++-v3/include/tr1/hashtable b/libstdc++-v3/include/tr1/hashtable index 07ac6a881a8c9ed4539024bf8f73617d8c342ec1..f4451b9033eddd0fe3e4eee962aaab61eacddcb8 100644 --- a/libstdc++-v3/include/tr1/hashtable +++ b/libstdc++-v3/include/tr1/hashtable @@ -73,8 +73,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) // _Key and _Value: arbitrary CopyConstructible types. // _Allocator: an allocator type ([lib.allocator.requirements]) whose - // value type is Value. - + // value type is Value. As a conforming extension, we allow for + // value type != Value. + // _ExtractKey: function object that takes a object of type Value // and returns a value of type _Key. @@ -106,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) // bucket count. If not, returns make_pair(false, <anything>). // ??? Right now it is hard-wired that the number of buckets never - // shrinks. Should we allow RehashPolicy to change that? + // shrinks. Should we allow _RehashPolicy to change that? // __cache_hash_code: bool. true if we store the value of the hash // function along with the value. This is a time-space tradeoff. @@ -154,8 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef _Value value_type; typedef _Key key_type; typedef _Equal key_equal; - // mapped_type, if present, comes from map_base. - // hasher, if present, comes from hash_code_base. + // mapped_type, if present, comes from _Map_base. + // hasher, if present, comes from _Hash_code_base. typedef typename _Allocator::difference_type difference_type; typedef typename _Allocator::size_type size_type; typedef typename _Allocator::reference reference; @@ -187,6 +188,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) typedef typename _Allocator::template rebind<_Node*>::other _Bucket_allocator_type; + typedef typename _Allocator::template rebind<_Value>::other + _Value_allocator_type; + _Node_allocator_type _M_node_allocator; _Node** _M_buckets; size_type _M_bucket_count; @@ -268,11 +272,15 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) allocator_type get_allocator() const - { return _M_node_allocator; } - + { return allocator_type(_M_node_allocator); } + + _Value_allocator_type + _M_get_Value_allocator() const + { return _Value_allocator_type(_M_node_allocator); } + size_type max_size() const - { return _M_node_allocator.max_size(); } + { return _M_get_Value_allocator().max_size(); } // Observers key_equal @@ -443,7 +451,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) _Node* __n = _M_node_allocator.allocate(1); try { - get_allocator().construct(&__n->_M_v, __v); + _M_get_Value_allocator().construct(&__n->_M_v, __v); __n->_M_next = 0; return __n; } @@ -463,7 +471,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _M_deallocate_node(_Node* __n) { - get_allocator().destroy(&__n->_M_v); + _M_get_Value_allocator().destroy(&__n->_M_v); _M_node_allocator.deallocate(__n, 1); } @@ -555,10 +563,10 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) _Hashtable<_Key, _Value, _Allocator, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>:: _Hashtable(_InputIterator __f, _InputIterator __l, - size_type __bucket_hint, - const _H1& __h1, const _H2& __h2, const _Hash& __h, - const _Equal& __eq, const _ExtractKey& __exk, - const allocator_type& __a) + size_type __bucket_hint, + const _H1& __h1, const _H2& __h2, const _Hash& __h, + const _Equal& __eq, const _ExtractKey& __exk, + const allocator_type& __a) : __detail::_Rehash_base<_RehashPolicy, _Hashtable>(), __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, __chc>(__exk, __eq, @@ -599,7 +607,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) __detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Equal, _H1, _H2, _Hash, __chc>(__ht), __detail::_Map_base<_Key, _Value, _ExtractKey, __uk, _Hashtable>(__ht), - _M_node_allocator(__ht.get_allocator()), + _M_node_allocator(__ht._M_node_allocator), _M_bucket_count(__ht._M_bucket_count), _M_element_count(__ht._M_element_count), _M_rehash_policy(__ht._M_rehash_policy) diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc new file mode 100644 index 0000000000000000000000000000000000000000..bce8f91567b2cc1e28e7f4e549c446289a10c467 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134-2.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include <deque> +#include <stdexcept> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque<int> d; + + try + { + d.resize(numeric_limits<size_t>::max()); + } + catch(const std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..b787f05db9fea608d0d256eac98750f8cad7e3e4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.2.1.2 deque capacity [lib.deque.capacity] + +#include <deque> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::deque<int> d; + + VERIFY( d.max_size() == d.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..513466565f62534cbca84c953986ff4652a9f116 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.2.2.2 list capacity [lib.list.capacity] + +#include <list> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<int> l; + + VERIFY( l.max_size() == l.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..6383eefa3ab1c6dc7a01be1a80f37c88b39b28ce --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.3.1 map capacity + +#include <map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::map<int, int> m; + + VERIFY( m.max_size() == m.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..466a3341f9e79fd02114a35115aae3cb26c795dd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.3.2 multimap capacity + +#include <map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::multimap<int, int> mm; + + VERIFY( mm.max_size() == mm.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..ddfb165e8d9b87333db1fc661cbe6de98a942801 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.3.4 multiset capacity + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::multiset<int> ms; + + VERIFY( ms.max_size() == ms.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..51650399b733b468c26db7ea0492714891969114 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.3.3 set capacity + +#include <set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::set<int> s; + + VERIFY( s.max_size() == s.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc new file mode 100644 index 0000000000000000000000000000000000000000..79a1d24ef78dd521fc567eec317a18efefd475a4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/29134-2.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.2.4.2 vector capacity [lib.vector.capacity] + +#include <vector> +#include <stdexcept> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + vector<int> v; + + try + { + v.resize(numeric_limits<size_t>::max()); + } + catch(const std::length_error&) + { + VERIFY( true ); + } + catch(...) + { + VERIFY( false ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc new file mode 100644 index 0000000000000000000000000000000000000000..5a98587954bc6183aa971a363a03caa741c0f211 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/capacity/29134.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 23.2.4.2 vector capacity [lib.vector.capacity] + +#include <vector> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector<int> v; + + VERIFY( v.max_size() == v.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-map.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-map.cc new file mode 100644 index 0000000000000000000000000000000000000000..459ace41a888e3259ca823f3a078ef02fed5c5e2 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-map.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 6.3.4.4 Class template unordered_map + +#include <tr1/unordered_map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::unordered_map<int, int> um; + + VERIFY( um.max_size() == um.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multimap.cc new file mode 100644 index 0000000000000000000000000000000000000000..af41fa154d6c158d60845314910eaa07995d4063 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multimap.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 6.3.4.6 Class template unordered_multimap + +#include <tr1/unordered_map> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::unordered_multimap<int, int> umm; + + VERIFY( umm.max_size() == umm.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multiset.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multiset.cc new file mode 100644 index 0000000000000000000000000000000000000000..923af9be118e71af4c2e78eb447a62954a603ce0 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-multiset.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 6.3.4.5 Class template unordered_multiset + +#include <tr1/unordered_set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::unordered_multiset<int> ums; + + VERIFY( ums.max_size() == ums.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-set.cc new file mode 100644 index 0000000000000000000000000000000000000000..5822341c85e0547162134c8b9f17adc4451e9379 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/capacity/29134-set.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2006 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 Pred 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. + +// 6.3.4.3 Class template unordered_set + +#include <tr1/unordered_set> +#include <testsuite_hooks.h> + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tr1::unordered_set<int> us; + + VERIFY( us.max_size() == us.get_allocator().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/map.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/map.cc index cb1cf2fc98e242ee51bd7aced2a16531d84996eb..41ce95db89e39d9ba6bb1ece523b14c92c686764 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/map.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/map.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern <austern@apple.com> // -// Copyright (C) 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006 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 @@ -32,3 +32,6 @@ template class unordered_map<string, float>; template class unordered_map<string, float, hash<string>, equal_to<string>, allocator<pair<const string, float> >, true>; +template class unordered_map<string, float, + hash<string>, equal_to<string>, + allocator<char>, false>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multimap.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multimap.cc index 73282612951f4afcb9740f09e9d2e7bc1f51701d..d48aef831b66cc1495279a8dfd8ab5a5bc231819 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multimap.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multimap.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern <austern@apple.com> // -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006 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 @@ -32,3 +32,6 @@ template class unordered_multimap<string, float>; template class unordered_multimap<string, float, hash<string>, equal_to<string>, allocator<pair<const string, float> >, true>; +template class unordered_multimap<string, float, + hash<string>, equal_to<string>, + allocator<char>, false>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multiset.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multiset.cc index e022e8bd8561c9dafc28bcdde28b8a503a999073..5d1e8710b05aac4a66ae8ce784c04072dfc65f3c 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multiset.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/multiset.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern <austern@apple.com> // -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006 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 @@ -30,3 +30,5 @@ using namespace std::tr1; template class unordered_multiset<int>; template class unordered_multiset<int, hash<int>, equal_to<int>, allocator<int>, true>; +template class unordered_multiset<int, hash<int>, equal_to<int>, + allocator<char>, false>; diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/set.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/set.cc index 9bb892eccd6480295680b81d9a59a47e71063a98..ae3214f1bae349c23913374c33429128188debe5 100644 --- a/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/set.cc +++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/instantiate/set.cc @@ -2,7 +2,7 @@ // 2005-02-17 Matt Austern <austern@apple.com> // -// Copyright (C) 2005 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006 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 @@ -30,3 +30,5 @@ using namespace std::tr1; template class unordered_set<int>; template class unordered_set<int, hash<int>, equal_to<int>, allocator<int>, true>; +template class unordered_set<int, hash<int>, equal_to<int>, + allocator<char>, false>;