libstdc++: make negative count safe with std::for_each_n
authorJonathan Wakely <jwakely@redhat.com>
Thu, 7 Nov 2019 23:10:45 +0000 (23:10 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 7 Nov 2019 23:10:45 +0000 (23:10 +0000)
commit3a99fd4dbb68c543299278c5bf5c04dfe93fc56c
tree56ed1610410711834769ead92c420b3250e73c37
parentb77cc8aa094c234e62814ddcc2230874b96aabf3
libstdc++: make negative count safe with std::for_each_n

The Library Working Group have approved a change to std::for_each_n that
requires it to handle negative N gracefully, which we were not doing for
random access iterators.

* include/bits/stl_algo.h (for_each_n): Handle negative count.
* testsuite/25_algorithms/for_each/for_each_n_debug.cc: New test.

From-SVN: r277932
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/testsuite/25_algorithms/for_each/for_each_n_debug.cc [new file with mode: 0644]