diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-03-03 16:16:05 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-03-03 22:46:39 -0500 |
commit | 712b182a8bc2d7510d7a2fbede43bf134c539f25 (patch) | |
tree | 92ab96c69c5f708552c8c4fbc2d2198d13941a19 /gcc/tree-tailcall.c | |
parent | 144dfc68d0c0f5b99a0cd0a14b211f82afed88c6 (diff) | |
download | gcc-712b182a8bc2d7510d7a2fbede43bf134c539f25.zip gcc-712b182a8bc2d7510d7a2fbede43bf134c539f25.tar.gz gcc-712b182a8bc2d7510d7a2fbede43bf134c539f25.tar.bz2 |
libstdc++: Fix incorrect use of memset in ranges::fill_n (PR 94017)
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.
Diffstat (limited to 'gcc/tree-tailcall.c')
0 files changed, 0 insertions, 0 deletions