aboutsummaryrefslogtreecommitdiff
path: root/gcc/varasm.cc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-01-03 15:01:09 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-01-05 10:23:35 +0000
commit15cc291887dc9dd92b2c93f4545e20eb6c190122 (patch)
tree8ed5f6860258fa70f9dd4b7e42e0d4453794a1d9 /gcc/varasm.cc
parent2cb3d42d3f3e7a5345ee7a6f3676a10c84864d72 (diff)
downloadgcc-15cc291887dc9dd92b2c93f4545e20eb6c190122.zip
gcc-15cc291887dc9dd92b2c93f4545e20eb6c190122.tar.gz
gcc-15cc291887dc9dd92b2c93f4545e20eb6c190122.tar.bz2
libstdc++: Fix std::char_traits<C>::move [PR113200]
The current constexpr implementation of std::char_traits<C>::move relies on being able to compare the pointer parameters, which is not allowed for unrelated pointers. We can use __builtin_constant_p to determine whether it's safe to compare the pointers directly. If not, then we know the ranges must be disjoint and so we can use char_traits<C>::copy to copy forwards from the first character to the last. If the pointers can be compared directly, then we can simplify the condition for copying backwards to just two pointer comparisons. libstdc++-v3/ChangeLog: PR libstdc++/113200 * include/bits/char_traits.h (__gnu_cxx::char_traits::move): Use __builtin_constant_p to check for unrelated pointers that cannot be compared during constant evaluation. * testsuite/21_strings/char_traits/requirements/113200.cc: New test.
Diffstat (limited to 'gcc/varasm.cc')
0 files changed, 0 insertions, 0 deletions