aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/src
diff options
context:
space:
mode:
authorFrançois Dumont <fdumont@gcc.gnu.org>2013-08-01 19:54:46 +0000
committerFrançois Dumont <fdumont@gcc.gnu.org>2013-08-01 19:54:46 +0000
commit5720787ada5aa74f244b3bc699f4abd991bee425 (patch)
treeed377bb0e83876a241613b80cb260f9f91684479 /libstdc++-v3/src
parent0bd729015ccfab7dd1d535fa7a7c17afbda28017 (diff)
downloadgcc-5720787ada5aa74f244b3bc699f4abd991bee425.zip
gcc-5720787ada5aa74f244b3bc699f4abd991bee425.tar.gz
gcc-5720787ada5aa74f244b3bc699f4abd991bee425.tar.bz2
re PR libstdc++/57779 (vector insert fails to diagnose iterators pointing into *this in debug mode)
2013-08-01 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/57779 * include/debug/formatter.h (_Debug_msg_id): Add __msg_insert_itself_range entry. * include/debug/functions.h (_Insert_range_from_self_is_safe<>): New, indicate container types supporting self range insertion in GNU implementation. (__foreign_iterator): New, check if an iterator points to a given sequence. * include/debug/macros.h (__glibcxx_check_insert_range): Add check using __foreign_iterator. (__gibcxx_check_insert_range_after): Likewise. * include/debug/string (_Insert_range_from_self_is_safe<>): Partially specialized to mark __gnu_debug::basic_string<> as supporting self range insert. * include/debug/list (_Insert_range_from_self_is_safe<>): Partially specialized to mark std::list as supporting self range insert if _GLIBCXX_DEBUG_PEDANTIC is not defined. * include/debug/forward_list (_Insert_range_from_self_is_safe<>): Likewise. * src/c++11/debug.cc (_S_debug_messages): Add __msg_insert_itself_range_entry message. (_Error_formatter::_Parameter::_M_print_description): Display iterator sequence address rather than sequence address when the parameter type is an iterator. (_Error_formatter::_M_print_word): Enhance behavior when displaying a word with an appended '\n'. * testsuite/util/debug/checks.h (check_insert4<>): New. * testsuite/23_containers/deque/debug/insert5_neg.cc: New. * testsuite/23_containers/vector/debug/insert5_neg.cc: Likewise. * testsuite/23_containers/vector/debug/insert6_neg.cc: Likewise. * testsuite/23_containers/vector/debug/57779_neg.cc: Likewise. * testsuite/23_containers/list/debug/insert5_neg.cc: Likewise. * testsuite/23_containers/forward_list/debug/insert_after4_neg.cc: Likewise. From-SVN: r201416
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r--libstdc++-v3/src/c++11/debug.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index 3655f39..260009c 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -181,7 +181,8 @@ namespace __gnu_debug
"attempt to access container with out-of-bounds bucket index %2;,"
" container only holds %3; buckets",
"load factor shall be positive",
- "allocators must be equal"
+ "allocators must be equal",
+ "attempt to insert with an iterator range [%1.name;, %2.name;) from this container"
};
void
@@ -695,7 +696,7 @@ namespace __gnu_debug
}
__formatter->_M_format_word(__buf, __bufsize, "@ 0x%p\n",
- _M_variant._M_sequence._M_address);
+ _M_variant._M_iterator._M_sequence);
__formatter->_M_print_word(__buf);
}
__formatter->_M_print_word("}\n");
@@ -808,8 +809,11 @@ namespace __gnu_debug
if (__length == 0)
return;
- if ((_M_column + __length < _M_max_length)
- || (__length >= _M_max_length && _M_column == 1))
+ size_t __visual_length
+ = __word[__length - 1] == '\n' ? __length - 1 : __length;
+ if (__visual_length == 0
+ || (_M_column + __visual_length < _M_max_length)
+ || (__visual_length >= _M_max_length && _M_column == 1))
{
// If this isn't the first line, indent
if (_M_column == 1 && !_M_first_line)
@@ -823,17 +827,17 @@ namespace __gnu_debug
}
fprintf(stderr, "%s", __word);
- _M_column += __length;
if (__word[__length - 1] == '\n')
{
_M_first_line = false;
_M_column = 1;
}
+ else
+ _M_column += __length;
}
else
{
- _M_column = 1;
_M_print_word("\n");
_M_print_word(__word);
}