New can_[in,de]crement_range debug checks
François Dumont
frs.dumont@gmail.com
Mon Jun 11 19:26:00 GMT 2018
Hi
   If not told otherwise I plan to commit attached patch tomorrow evening.
   It is adding new Debug checks to find out if an output iterator
will always be reachable while looping on an input range. Note that this
check was already done previously by checking if the iterator was
[in,de]crementable but it will now assert before any operation take
place. I also need it in order to remove debug layer on the output
iterator in a future patch.
   I am also adding some tests on the std::equal algorithm because I
plan to apply those macros to this algo too but users can append a
special value at the end of the 2nd range to make sure it will never go
beyond this position. Some tests are doing this and was triggering the
Debug check.
   * include/debug/macros.h (__glibcxx_check_can_increment_range): New.
   (__glibcxx_check_can_decrement_range): New.
   * include/debug/debug.h (__glibcxx_requires_can_increment_range): New.
   (__glibcxx_requires_can_decrement_range): New.
   * include/bits/stl_algobase.h (std::copy(_II, _II, _OI)): Use
   __glibcxx_requires_can_increment_range.
   (std::move(_II, _II, _OI)): Likewise.
   (std::copy_backward(_BI, _BI, _BI2)): Use
   __glibcxx_requires_can_decrement_range.
   (std::move_backward(_BI, _BI, _BI2)): Likewise.
   * testsuite/25_algorithms/copy_backward/debug/1_neg.cc: New.
   * testsuite/25_algorithms/copy_backward/debug/2_neg.cc: New.
   * testsuite/25_algorithms/copy_backward/debug/3_neg.cc: New.
   * testsuite/25_algorithms/equal/debug/1_neg.cc: New.
   * testsuite/25_algorithms/equal/debug/2_neg.cc: New.
   * testsuite/25_algorithms/equal/debug/3_neg.cc: New.
Tested under Linux x86_64, normal and debug modes.
François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: can_increment.patch
Type: text/x-patch
Size: 15389 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20180611/248a3cfb/attachment.bin>
More information about the Libstdc++
mailing list