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.
| Name | Last commit | Last update | 
|---|---|---|
| .. | ||
| adjacent_find | Loading commit data... | |
| advance/istreambuf_iterators | Loading commit data... | |
| all_of | Loading commit data... | |
| any_of | Loading commit data... | |
| binary_search | Loading commit data... | |
| clamp | Loading commit data... | |
| copy | Loading commit data... | |
| copy_backward | Loading commit data... | |
| copy_if | Loading commit data... | |
| copy_n | Loading commit data... | |
| count | Loading commit data... | |
| count_if | Loading commit data... | |
| equal | Loading commit data... | |
| equal_range | Loading commit data... | |
| fill | Loading commit data... | |
| fill_n | Loading commit data... | |
| find | Loading commit data... | |
| find_end | Loading commit data... | |
| find_first_of | Loading commit data... | |
| find_if | Loading commit data... | |
| find_if_not | Loading commit data... | |
| for_each | Loading commit data... | |
| generate | Loading commit data... | |
| generate_n | Loading commit data... | |
| headers | Loading commit data... | |
| heap | Loading commit data... | |
| includes | Loading commit data... | |
| inplace_merge | Loading commit data... | |
| is_heap | Loading commit data... | |
| is_heap_until | Loading commit data... | |
| is_partitioned | Loading commit data... | |
| is_permutation | Loading commit data... | |
| is_sorted | Loading commit data... | |
| is_sorted_until | Loading commit data... | |
| iter_swap | Loading commit data... | |
| lexicographical_compare | Loading commit data... | |
| lexicographical_compare_three_way | Loading commit data... | |
| lower_bound | Loading commit data... | |
| make_heap | Loading commit data... | |
| max | Loading commit data... | |
| max_element | Loading commit data... | |
| merge | Loading commit data... | |
| min | Loading commit data... | |
| min_element | Loading commit data... | |
| minmax | Loading commit data... | |
| minmax_element | Loading commit data... | |
| mismatch | Loading commit data... | |
| move | Loading commit data... | |
| move_backward | Loading commit data... | |
| next_permutation | Loading commit data... | |
| none_of | Loading commit data... | |
| nth_element | Loading commit data... | |
| partial_sort | Loading commit data... | |
| partial_sort_copy | Loading commit data... | |
| partition | Loading commit data... | |
| partition_copy | Loading commit data... | |
| partition_point | Loading commit data... | |
| pop_heap | Loading commit data... | |
| prev_permutation | Loading commit data... | |
| pstl | Loading commit data... | |
| push_heap | Loading commit data... | |
| random_shuffle | Loading commit data... | |
| remove | Loading commit data... | |
| remove_copy | Loading commit data... | |
| remove_copy_if | Loading commit data... | |
| remove_if | Loading commit data... | |
| replace | Loading commit data... | |
| replace_copy | Loading commit data... | |
| replace_copy_if | Loading commit data... | |
| replace_if | Loading commit data... | |
| reverse | Loading commit data... | |
| reverse_copy | Loading commit data... | |
| rotate | Loading commit data... | |
| rotate_copy | Loading commit data... | |
| sample | Loading commit data... | |
| search | Loading commit data... | |
| search_n | Loading commit data... | |
| set_difference | Loading commit data... | |
| set_intersection | Loading commit data... | |
| set_symmetric_difference | Loading commit data... | |
| set_union | Loading commit data... | |
| shift_left | Loading commit data... | |
| shift_right | Loading commit data... | |
| shuffle | Loading commit data... | |
| sort | Loading commit data... | |
| sort_heap | Loading commit data... | |
| stable_partition | Loading commit data... | |
| stable_sort | Loading commit data... | |
| swap | Loading commit data... | |
| swap_ranges | Loading commit data... | |
| transform | Loading commit data... | |
| unique | Loading commit data... | |
| unique_copy | Loading commit data... | |
| upper_bound | Loading commit data... | |
| constexpr_macro.cc | Loading commit data... | |
| cpp_lib_constexpr.cc | Loading commit data... |