[PATCH] PR libstdc++/87982 Fix generate_n and fill_n use of _Size parameter

Jonathan Wakely jwakely@redhat.com
Mon Apr 29 13:32:00 GMT 2019


On 29/04/19 13:13 +0100, Jonathan Wakely wrote:
>    The standard only requires that _Size can be converted to an integral
>    type, not that it can be used for arithmetic. Add a new set of
>    __size_to_integer helper functions to do the conversion (which will be
>    ambiguous if there is no one conversion that is better than any others).
>
>    Also add tests for DR 426 which requires these algorithms and search_n
>    to handle negative values of n.
>
>            PR libstdc++/87982
>            * include/bits/stl_algo.h (generate_n): Convert _Size parameter to
>            an integral type.
>            * include/bits/stl_algobase.h (__size_to_integer): New overloaded
>            functions to convert a value to an integral type.
>            (__fill_n_a, __fill_n_a): Assert that __n is already an integral type.
>            (fill_n): Convert _Size parameter to an integral type.
>            * testsuite/25_algorithms/fill_n/dr426.cc: New test.
>            * testsuite/25_algorithms/generate_n/87982.cc: New test.
>            * testsuite/25_algorithms/generate_n/dr426.cc: New test.
>
>diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
>index cb870c41dc1..ae9bb8f14b0 100644
>--- a/libstdc++-v3/include/bits/stl_algo.h
>+++ b/libstdc++-v3/include/bits/stl_algo.h
>@@ -4433,9 +4433,11 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
>    *  Performs the assignment @c *i = @p __gen() for each @c i in the range
>    *  @p [__first,__first+__n).
>    *
>-   *  _GLIBCXX_RESOLVE_LIB_DEFECTS
>-   *  DR 865. More algorithms that throw away information
>+   * If @p __n is negative, the function does nothing.

I've committed a further tweak to this comment.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 877 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190429/c65acbbc/attachment.bin>


More information about the Libstdc++ mailing list