]> git.ipfire.org Git - thirdparty/gcc.git/commit - libstdc++-v3/include/bits/stl_algobase.h
PR libstdc++/89164 enforce constraints for uninitialized algos
authorJonathan Wakely <jwakely@redhat.com>
Fri, 30 Aug 2019 13:54:49 +0000 (14:54 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 30 Aug 2019 13:54:49 +0000 (14:54 +0100)
commit61f5cb2313f7a3336264eeabbe9fbaccd00e49a0
tree53f8e4e427d2ccaad0a38927a6710a48c9bef542
parent815b53683243f09194a9a0af270cde060c2d58e7
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.

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.

From-SVN: r275177
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/bits/stl_uninitialized.h
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/89164.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/89164.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/89164.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/89164.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/cons/89164.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc [new file with mode: 0644]