Several algorithms check the is_trivially_copyable trait to decide whether to dispatch to memmove or memcmp as an optimization. Since r271435 (CWG DR 2094) the trait is true for volatile-qualified scalars, but we can't use memmove or memcmp when the type is volatile. We need to also check for volatile types. This is complicated by the fact that in C++20 (but not earlier standards) iterator_traits<volatile T*>::value_type is T, so we can't just check whether the value_type is volatile. The solution in this patch is to introduce new traits __memcpyable and __memcmpable which combine into a single trait the checks for pointers, the value types being the same, and the type being trivially copyable but not volatile-qualified. PR libstdc++/94013 * include/bits/cpp_type_traits.h (__memcpyable, __memcmpable): New traits to control when to use memmove and memcmp optimizations. (__is_nonvolatile_trivially_copyable): New helper trait. * include/bits/ranges_algo.h (__lexicographical_compare_fn): Do not use memcmp optimization with volatile data. * include/bits/ranges_algobase.h (__equal_fn): Use __memcmpable. (__copy_or_move, __copy_or_move_backward): Use __memcpyable. * include/bits/stl_algobase.h (__copy_move_a2): Use __memcpyable. (__copy_move_backward_a2): Likewise. (__equal_aux1): Use __memcmpable. (__lexicographical_compare_aux): Do not use memcmp optimization with volatile data. * testsuite/25_algorithms/copy/94013.cc: New test. * testsuite/25_algorithms/copy_backward/94013.cc: New test. * testsuite/25_algorithms/equal/94013.cc: New test. * testsuite/25_algorithms/fill/94013.cc: New test. * testsuite/25_algorithms/lexicographical_compare/94013.cc: New test. * testsuite/25_algorithms/move/94013.cc: New test. * testsuite/25_algorithms/move_backward/94013.cc: New test.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
config | Loading commit data... | |
doc | Loading commit data... | |
include | Loading commit data... | |
libsupc++ | Loading commit data... | |
po | Loading commit data... | |
python | Loading commit data... | |
scripts | Loading commit data... | |
src | Loading commit data... | |
testsuite | Loading commit data... | |
ChangeLog | Loading commit data... | |
ChangeLog-1998 | Loading commit data... | |
ChangeLog-1999 | Loading commit data... | |
ChangeLog-2000 | Loading commit data... | |
ChangeLog-2001 | Loading commit data... | |
ChangeLog-2002 | Loading commit data... | |
ChangeLog-2003 | Loading commit data... | |
ChangeLog-2004 | Loading commit data... | |
ChangeLog-2005 | Loading commit data... | |
ChangeLog-2006 | Loading commit data... | |
ChangeLog-2007 | Loading commit data... | |
ChangeLog-2008 | Loading commit data... | |
ChangeLog-2009 | Loading commit data... | |
ChangeLog-2010 | Loading commit data... | |
ChangeLog-2011 | Loading commit data... | |
ChangeLog-2012 | Loading commit data... | |
ChangeLog-2013 | Loading commit data... | |
ChangeLog-2014 | Loading commit data... | |
ChangeLog-2015 | Loading commit data... | |
ChangeLog-2016 | Loading commit data... | |
ChangeLog-2017 | Loading commit data... | |
ChangeLog-2018 | Loading commit data... | |
ChangeLog-2019 | Loading commit data... | |
Makefile.am | Loading commit data... | |
Makefile.in | Loading commit data... | |
README | Loading commit data... | |
acinclude.m4 | Loading commit data... | |
aclocal.m4 | Loading commit data... | |
config.h.in | Loading commit data... | |
configure | Loading commit data... | |
configure.ac | Loading commit data... | |
configure.host | Loading commit data... | |
crossconfig.m4 | Loading commit data... | |
fragment.am | Loading commit data... | |
linkage.m4 | Loading commit data... |