diff options
author | Glen Joseph Fernandes <glenjofe@gmail.com> | 2018-07-19 18:58:09 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-07-19 19:58:09 +0100 |
commit | 20a0c4e3dc9948b3d182943c8c47d4608c0bec9d (patch) | |
tree | 500cad43dc4c24b022a0c08425ee6eec7c420d7c | |
parent | 0d21482100aebb2b53948af330e9f3eb3fe1d9a7 (diff) | |
download | gcc-20a0c4e3dc9948b3d182943c8c47d4608c0bec9d.zip gcc-20a0c4e3dc9948b3d182943c8c47d4608c0bec9d.tar.gz gcc-20a0c4e3dc9948b3d182943c8c47d4608c0bec9d.tar.bz2 |
Use __builtin_memmove for trivially copyable types
2018-07-19 Glen Joseph Fernandes <glenjofe@gmail.com>
* include/bits/stl_algobase.h (__copy_move_a): Used
__is_trivially_copyable.
(__copy_move_backward_a): Likewise.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc:
New test.
From-SVN: r262884
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algobase.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc | 37 |
3 files changed, 47 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4345d29..00bcf2d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2018-07-19 Glen Joseph Fernandes <glenjofe@gmail.com> + + * include/bits/stl_algobase.h (__copy_move_a): Used + __is_trivially_copyable. + (__copy_move_backward_a): Likewise. + * testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc: + New test. + 2018-07-17 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/86450 diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 16a3f83..f0130bc 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -391,7 +391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef typename iterator_traits<_II>::value_type _ValueTypeI; typedef typename iterator_traits<_OI>::value_type _ValueTypeO; typedef typename iterator_traits<_II>::iterator_category _Category; - const bool __simple = (__is_trivial(_ValueTypeI) + const bool __simple = (__is_trivially_copyable(_ValueTypeI) && __is_pointer<_II>::__value && __is_pointer<_OI>::__value && __are_same<_ValueTypeI, _ValueTypeO>::__value); @@ -593,7 +593,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef typename iterator_traits<_BI1>::value_type _ValueType1; typedef typename iterator_traits<_BI2>::value_type _ValueType2; typedef typename iterator_traits<_BI1>::iterator_category _Category; - const bool __simple = (__is_trivial(_ValueType1) + const bool __simple = (__is_trivially_copyable(_ValueType1) && __is_pointer<_BI1>::__value && __is_pointer<_BI2>::__value && __are_same<_ValueType1, _ValueType2>::__value); diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc new file mode 100644 index 0000000..461d1f2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do compile { target c++11 } } + +#include <memory> + +struct T +{ + T() { } + T(const T&) = delete; +}; + +static_assert(__is_trivially_assignable(T&, const T&) && + !__is_trivial(T), "T is only trivially copy assignable"); + +void +test01(T* result) +{ + T t[1]; + std::uninitialized_copy(t, t+1, result); // { dg-error "here" } +} +// { dg-prune-output "use of deleted function" } |