]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR libstdc++/87982 Fix generate_n and fill_n use of _Size parameter
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Apr 2019 12:12:43 +0000 (12:12 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Apr 2019 12:12:43 +0000 (12:12 +0000)
commitc5aaf0af76b05586da4e617acb33215903933d4f
treeacdd7472ab025aaa6f9568c19f2a8c0e154a506c
parent9076bd460c7892f184b95cd6c88e43f1fe8ff630
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270646 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/testsuite/25_algorithms/fill_n/87982.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/fill_n/87982_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/fill_n/dr426.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/generate_n/87982.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/generate_n/87982_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/25_algorithms/generate_n/dr426.cc [new file with mode: 0644]