https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87982

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Apr 29 12:12:43 2019
New Revision: 270646

URL: https://gcc.gnu.org/viewcvs?rev=270646&root=gcc&view=rev
Log:
PR libstdc++/87982 Fix generate_n and fill_n use of _Size parameter

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.

Added:
    trunk/libstdc++-v3/testsuite/25_algorithms/fill_n/87982.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/fill_n/87982_neg.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/fill_n/dr426.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/generate_n/87982.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/generate_n/87982_neg.cc
    trunk/libstdc++-v3/testsuite/25_algorithms/generate_n/dr426.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_algo.h
    trunk/libstdc++-v3/include/bits/stl_algobase.h

Reply via email to