gcc/libstdc++-v3/testsuite/util
Jonathan Wakely e1008cd1d8 libstdc++: Make std::copy_n work with negative and non-integral sizes
Since it was added in C++11, std::copy_n and std::ranges::copy_n should
do nothing given a negative size, but for random access iterators we add
the size to the iterator, possibly resulting in undefined behaviour.

Also, C++20 clarified that std::copy_n requires the Size type to be
convertible to an integral type. We previously assumed that it could be
directly used in arithmetic expressions, without conversion to an
integral type.

This also fixes a bug in the random_access_iterator_wrapper helper adds
some convenience aliases for using the iterator wrappers.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h (__copy_n_fn): Only call
	ranges::copy for positive values.
	* include/bits/stl_algo.h (copy_n): Convert Size argument to an
	integral type and only call __copy_n for positive values.
	* testsuite/util/testsuite_iterators.h
	(random_access_iterator_wrapper::operator+=): Fix range check for
	negative values.
	(output_container, input_container, forward_container)
	(bidirectional_container, random_access_container): New alias
	templates.
	* testsuite/25_algorithms/copy_n/5.cc: New test.
2020-06-04 14:21:34 +01:00
..
common_type
debug
exception
hash_fn
io
native_type
performance
pstl
regression
statistic
thread
replacement_memory_operators.h
slow_clock.h
specfun_testcase.h
testsuite_abi_check.cc
testsuite_abi.cc
testsuite_abi.h
testsuite_allocator.cc
testsuite_allocator.h
testsuite_api.h
testsuite_character.cc
testsuite_character.h
testsuite_common_types.h
testsuite_container_traits.h
testsuite_containergen.h
testsuite_containers.h
testsuite_counter_type.h
testsuite_error.h
testsuite_fs.h
testsuite_greedy_ops.h
testsuite_hooks.cc
testsuite_hooks.h
testsuite_io.h
testsuite_iterators.h
testsuite_new_operators.h
testsuite_performance.h
testsuite_random.h
testsuite_regex.h
testsuite_rng.h
testsuite_rvalref.h
testsuite_shared.cc
testsuite_tr1.h