[Bug libstdc++/89164] can construct vector with non-copyable-but-trivially-copyable elements
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 24 12:55:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89164
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Oct 24 12:54:58 2019
New Revision: 277388
URL: https://gcc.gnu.org/viewcvs?rev=277388&root=gcc&view=rev
Log:
PR libstdc++/89164 enforce constraints for uninitialized algos
The memmove optimizations for std::uninitialized_copy/fill/_n will
compile even if the type is not copy constructible, because std::copy
doesn't require copy construction to work. But the uninitialized
algorithms do require it.
This adds explicit static assertions to ensure we don't allow ill-formed
initializations.
Backport from mainline
2019-08-30 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/89164
* include/bits/stl_algobase.h (__copy_move): Give descriptive names
to template parameters.
* include/bits/stl_uninitialized.h (uninitialized_copy)
(uninitialized_fill, uninitialized_fill_n): Add static assertions to
diagnose invalid uses.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc:
Adjust expected error.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_copy_n/
89164.cc: New test.
* testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc:
New test.
* testsuite/20_util/specialized_algorithms/uninitialized_fill_n/
89164.cc: New test.
* testsuite/23_containers/vector/cons/89164.cc: New test.
* testsuite/23_containers/vector/cons/89164_c++17.cc: New test.
Added:
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc
- copied, changed from r277387,
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/89164.cc
- copied, changed from r277387,
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc
- copied, changed from r277387,
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/89164.cc
- copied, changed from r277387,
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/23_containers/vector/cons/89164.cc
- copied, changed from r277387,
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
branches/gcc-9-branch/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc
Modified:
branches/gcc-9-branch/libstdc++-v3/ChangeLog
branches/gcc-9-branch/libstdc++-v3/include/bits/stl_algobase.h
branches/gcc-9-branch/libstdc++-v3/include/bits/stl_uninitialized.h
branches/gcc-9-branch/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
More information about the Gcc-bugs
mailing list