This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR libstdc++/89164 enforce constraints for uninitialized algos


On 30/08/19 14:54 +0100, Jonathan Wakely wrote:
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.

This is the patch sent in
https://gcc.gnu.org/ml/libstdc++/2019-02/msg00034.html but with the
dg-error directives in the tests fixed.

Tested x86_64-linux, committed to trunk.

Oops, looks like what I tested didn't have the new test checked in.
This fixes it.


commit 01e0d7b3957c4bd8cdac86e0e4f16135dc61d51c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Aug 30 17:18:17 2019 +0100

    Fix errors in new test
    
            * testsuite/23_containers/vector/cons/89164_c++17.cc: Fix errors.

diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc
index 8b3afba4867..db7d8d5c850 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/89164_c++17.cc
@@ -22,6 +22,12 @@
 
 // PR libstdc++/89164
 
+struct X
+{
+  X() = default;
+  X(const X&) = delete;
+};
+
 void test01()
 {
   X x[1];

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]