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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Jonathan Wakely-3
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.



patch.txt (727 bytes) Download Attachment