summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include/debug
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-16 19:57:03 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-16 19:57:03 +0000
commit698c853f3099b376d4a587d86b3f3c8eae04db74 (patch)
tree3ed45405b807551cb4b195fd6fafab832b78474e /libstdc++-v3/include/debug
parentbbdfcf3462b7fc2bd01b59c380f1420170f819da (diff)
downloadppe42-gcc-698c853f3099b376d4a587d86b3f3c8eae04db74.tar.gz
ppe42-gcc-698c853f3099b376d4a587d86b3f3c8eae04db74.zip
2012-10-16 François Dumont <fdumont@gcc.gnu.org>
* include/debug/formatter.h (_Debug_msg_id): Add __msg_bucket_index_oob. * include/debug/macros.h (__glibcxx_check_bucket_index): New. * include/debug/unordered_set (unordered_set<>::begin(size_type)): Add check on bucket index. (unordered_set<>::begin(size_type) const): Likewise. (unordered_set<>::cbegin(size_type) const): Likewise. (unordered_set<>::end(size_type)): Likewise. (unordered_set<>::end(size_type) const): Likewise. (unordered_set<>::cend(size_type) const): Likewise. (unordered_set<>::bucket_size(size_type)): Likewise. (unordered_multiset<>::begin(size_type)): Likewise. (unordered_multiset<>::begin(size_type) const): Likewise. (unordered_multiset<>::cbegin(size_type) const): Likewise. (unordered_multiset<>::end(size_type)): Likewise. (unordered_multiset<>::end(size_type) const): Likewise. (unordered_multiset<>::cend(size_type) const): Likewise. (unordered_multiset<>::bucket_size(size_type)): Likewise. * include/debug/unordered_map (unordered_map<>::begin(size_type)): Likewise. (unordered_map<>::begin(size_type) const): Likewise. (unordered_map<>::cbegin(size_type) const): Likewise. (unordered_map<>::end(size_type)): Likewise. (unordered_map<>::end(size_type) const): Likewise. (unordered_map<>::cend(size_type) const): Likewise. (unordered_map<>::bucket_size(size_type)): Likewise. (unordered_multimap<>::begin(size_type)): Likewise. (unordered_multimap<>::begin(size_type) const): Likewise. (unordered_multimap<>::cbegin(size_type) const): Likewise. (unordered_multimap<>::end(size_type)): Likewise. (unordered_multimap<>::end(size_type) const): Likewise. (unordered_multimap<>::cend(size_type) const): Likewise. (unordered_multimap<>::bucket_size(size_type)): Likewise. * testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc: New. * testsuite/23_containers/unordered_map/debug/begin1_neg.cc: New. * testsuite/23_containers/unordered_map/debug/begin2_neg.cc: New. * testsuite/23_containers/unordered_map/debug/cbegin_neg.cc: New. * testsuite/23_containers/unordered_map/debug/end1_neg.cc: New. * testsuite/23_containers/unordered_map/debug/end2_neg.cc: New. * testsuite/23_containers/unordered_map/debug/cend_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/end1_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/end2_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/cend_neg.cc: New. * testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc: New. * testsuite/23_containers/unordered_set/debug/begin1_neg.cc: New. * testsuite/23_containers/unordered_set/debug/begin2_neg.cc: New. * testsuite/23_containers/unordered_set/debug/cbegin_neg.cc: New. * testsuite/23_containers/unordered_set/debug/end1_neg.cc: New. * testsuite/23_containers/unordered_set/debug/end2_neg.cc: New. * testsuite/23_containers/unordered_set/debug/cend_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/end1_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/end2_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/cend_neg.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192512 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r--libstdc++-v3/include/debug/formatter.h6
-rw-r--r--libstdc++-v3/include/debug/macros.h10
-rw-r--r--libstdc++-v3/include/debug/unordered_map74
-rw-r--r--libstdc++-v3/include/debug/unordered_set74
4 files changed, 137 insertions, 27 deletions
diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h
index 8f36285ff17..9bed99821e9 100644
--- a/libstdc++-v3/include/debug/formatter.h
+++ b/libstdc++-v3/include/debug/formatter.h
@@ -107,11 +107,13 @@ namespace __gnu_debug
__msg_insert_after_end,
__msg_erase_after_bad,
__msg_valid_range2,
- // unordered sequence local iterators
+ // unordered container local iterators
__msg_local_iter_compare_bad,
__msg_non_empty_range,
// self move assign
- __msg_self_move_assign
+ __msg_self_move_assign,
+ // unordered container buckets
+ __msg_bucket_index_oob
};
class _Error_formatter
diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h
index 1b7871957ee..a8e2f5facb7 100644
--- a/libstdc++-v3/include/debug/macros.h
+++ b/libstdc++-v3/include/debug/macros.h
@@ -202,11 +202,19 @@ _GLIBCXX_DEBUG_VERIFY(!_Last._M_is_before_begin(), \
// Verify that the subscript _N is less than the container's size.
#define __glibcxx_check_subscript(_N) \
_GLIBCXX_DEBUG_VERIFY(_N < this->size(), \
- _M_message(__gnu_debug::__msg_subscript_oob) \
+ _M_message(__gnu_debug::__msg_subscript_oob) \
._M_sequence(*this, "this") \
._M_integer(_N, #_N) \
._M_integer(this->size(), "size"))
+// Verify that the bucket _N is less than the container's buckets count.
+#define __glibcxx_check_bucket_index(_N) \
+_GLIBCXX_DEBUG_VERIFY(_N < this->bucket_count(), \
+ _M_message(__gnu_debug::__msg_bucket_index_oob) \
+ ._M_sequence(*this, "this") \
+ ._M_integer(_N, #_N) \
+ ._M_integer(this->bucket_count(), "size"))
+
// Verify that the container is nonempty
#define __glibcxx_check_nonempty() \
_GLIBCXX_DEBUG_VERIFY(! this->empty(), \
diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map
index 96cb148ebb5..e980d8ce4f1 100644
--- a/libstdc++-v3/include/debug/unordered_map
+++ b/libstdc++-v3/include/debug/unordered_map
@@ -183,27 +183,52 @@ namespace __debug
// local versions
local_iterator
begin(size_type __b)
- { return local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::begin(__b), __b, this);
+ }
local_iterator
end(size_type __b)
- { return local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
begin(size_type __b) const
- { return const_local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::begin(__b), __b, this);
+ }
const_local_iterator
end(size_type __b) const
- { return const_local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
cbegin(size_type __b) const
- { return const_local_iterator(_Base::cbegin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cbegin(__b), __b, this);
+ }
const_local_iterator
cend(size_type __b) const
- { return const_local_iterator(_Base::cend(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cend(__b), __b, this);
+ }
+
+ size_type
+ bucket_size(size_type __b) const
+ {
+ __glibcxx_check_bucket_index(__b);
+ return _Base::bucket_size(__b);
+ }
template<typename... _Args>
std::pair<iterator, bool>
@@ -598,27 +623,52 @@ namespace __debug
// local versions
local_iterator
begin(size_type __b)
- { return local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::begin(__b), __b, this);
+ }
local_iterator
end(size_type __b)
- { return local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
begin(size_type __b) const
- { return const_local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::begin(__b), __b, this);
+ }
const_local_iterator
end(size_type __b) const
- { return const_local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
cbegin(size_type __b) const
- { return const_local_iterator(_Base::cbegin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cbegin(__b), __b, this);
+ }
const_local_iterator
cend(size_type __b) const
- { return const_local_iterator(_Base::cend(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cend(__b), __b, this);
+ }
+
+ size_type
+ bucket_size(size_type __b) const
+ {
+ __glibcxx_check_bucket_index(__b);
+ return _Base::bucket_size(__b);
+ }
template<typename... _Args>
iterator
diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set
index 7996763829f..276821d7e83 100644
--- a/libstdc++-v3/include/debug/unordered_set
+++ b/libstdc++-v3/include/debug/unordered_set
@@ -183,27 +183,52 @@ namespace __debug
// local versions
local_iterator
begin(size_type __b)
- { return local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::begin(__b), __b, this);
+ }
local_iterator
end(size_type __b)
- { return local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
begin(size_type __b) const
- { return const_local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::begin(__b), __b, this);
+ }
const_local_iterator
end(size_type __b) const
- { return const_local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
cbegin(size_type __b) const
- { return const_local_iterator(_Base::cbegin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cbegin(__b), __b, this);
+ }
const_local_iterator
cend(size_type __b) const
- { return const_local_iterator(_Base::cend(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cend(__b), __b, this);
+ }
+
+ size_type
+ bucket_size(size_type __b) const
+ {
+ __glibcxx_check_bucket_index(__b);
+ return _Base::bucket_size(__b);
+ }
template<typename... _Args>
std::pair<iterator, bool>
@@ -593,27 +618,52 @@ namespace __debug
// local versions
local_iterator
begin(size_type __b)
- { return local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::begin(__b), __b, this);
+ }
local_iterator
end(size_type __b)
- { return local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
begin(size_type __b) const
- { return const_local_iterator(_Base::begin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::begin(__b), __b, this);
+ }
const_local_iterator
end(size_type __b) const
- { return const_local_iterator(_Base::end(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::end(__b), __b, this);
+ }
const_local_iterator
cbegin(size_type __b) const
- { return const_local_iterator(_Base::cbegin(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cbegin(__b), __b, this);
+ }
const_local_iterator
cend(size_type __b) const
- { return const_local_iterator(_Base::cend(__b), __b, this); }
+ {
+ __glibcxx_check_bucket_index(__b);
+ return const_local_iterator(_Base::cend(__b), __b, this);
+ }
+
+ size_type
+ bucket_size(size_type __b) const
+ {
+ __glibcxx_check_bucket_index(__b);
+ return _Base::bucket_size(__b);
+ }
template<typename... _Args>
iterator
OpenPOWER on IntegriCloud