712b182a8b
When deciding whether to perform the memset optimization in ranges::fill_n, we were crucially neglecting to check that the output pointer's value type is a byte type. This patch adds such a check to the problematic condition in ranges::fill_n. At the same time, this patch relaxes the overly conservative __is_byte<_Tp>::__value check that requires the fill type be a byte type. It's overly conservative because it means we won't enable the memset optimization in the following example char c[100]; ranges::fill(c, 37); because the fill type is deduced to be int here. Rather than requiring that the fill type be a byte type, it seems safe to just require the fill type be an integral type, which is what this patch does. libstdc++-v3/ChangeLog: PR libstdc++/94017 * include/bits/ranges_algobase.h (__fill_n_fn::operator()): Refine condition for when to use memset, making sure to additionally check that the output pointer's value type is a non-volatile byte type. Instead of requiring that the fill type is a byte type, just require that it's an integral type. * testsuite/20_util/specialized_algorithms/uninitialized_fill/94017.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/94017.cc: New test. * testsuite/25_algorithms/fill/94013.cc: Uncomment part that was blocked by PR 94017. * testsuite/25_algorithms/fill/94017.cc: New test. * testsuite/25_algorithms/fill_n/94017.cc: New test. |
||
---|---|---|
.. | ||
adjacent_find | ||
advance/istreambuf_iterators | ||
all_of | ||
any_of | ||
binary_search | ||
clamp | ||
copy | ||
copy_backward | ||
copy_if | ||
copy_n | ||
count | ||
count_if | ||
equal | ||
equal_range | ||
fill | ||
fill_n | ||
find | ||
find_end | ||
find_first_of | ||
find_if | ||
find_if_not | ||
for_each | ||
generate | ||
generate_n | ||
headers | ||
heap | ||
includes | ||
inplace_merge | ||
is_heap | ||
is_heap_until | ||
is_partitioned | ||
is_permutation | ||
is_sorted | ||
is_sorted_until | ||
iter_swap | ||
lexicographical_compare | ||
lexicographical_compare_three_way | ||
lower_bound | ||
make_heap | ||
max | ||
max_element | ||
merge | ||
min | ||
min_element | ||
minmax | ||
minmax_element | ||
mismatch | ||
move | ||
move_backward | ||
next_permutation | ||
none_of | ||
nth_element | ||
partial_sort | ||
partial_sort_copy | ||
partition | ||
partition_copy | ||
partition_point | ||
pop_heap | ||
prev_permutation | ||
pstl | ||
push_heap | ||
random_shuffle | ||
remove | ||
remove_copy | ||
remove_copy_if | ||
remove_if | ||
replace | ||
replace_copy | ||
replace_copy_if | ||
replace_if | ||
reverse | ||
reverse_copy | ||
rotate | ||
rotate_copy | ||
sample | ||
search | ||
search_n | ||
set_difference | ||
set_intersection | ||
set_symmetric_difference | ||
set_union | ||
shift_left | ||
shift_right | ||
shuffle | ||
sort | ||
sort_heap | ||
stable_partition | ||
stable_sort | ||
swap | ||
swap_ranges | ||
transform | ||
unique | ||
unique_copy | ||
upper_bound | ||
constexpr_macro.cc | ||
cpp_lib_constexpr.cc |