On 21/09/20 16:01 +0100, Jonathan Wakely wrote:
On 18/09/20 21:08 -0400, Patrick Palka via Libstdc++ wrote:
This fixes a division by zero in the selection-sampling std::__search
overload when the input range is empty (and hence __unsampled_sz is 0).

Tested on x86_64-pc-linux-gnu.

libstdc++-v3/ChangeLog:

        * include/bits/stl_algo.h (__sample): Exit early when the
        input range is empty.
        * testsuite/25_algorithms/sample/3.cc: New test.
---
libstdc++-v3/include/bits/stl_algo.h          |  3 ++
.../testsuite/25_algorithms/sample/3.cc       | 50 +++++++++++++++++++
2 files changed, 53 insertions(+)
create mode 100644 libstdc++-v3/testsuite/25_algorithms/sample/3.cc

OK, thanks.

Could you please backport this to all branches too.


Reply via email to