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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:f0eb0ba218968715506c435ca4ff71043e86617c

commit r14-11184-gf0eb0ba218968715506c435ca4ff71043e86617c
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Dec 3 16:36:05 2024 +0000

    libstdc++: Fix parallel std::exclusive_scan [PR108236]

    The standard says that std::exclusive_scan can be used to work in
    place, i.e. where the output range is the same as the input range. This
    means that the first sum cannot be written to the output until after
    reading the first input value, otherwise we'll already have overwritten
    the first input value.

    While writing a new testcase I also realised that the serial version of
    std::exclusive_scan uses copy construction for the accumulator variable,
    but the standard only requires Cpp17MoveConstructible. We also require
    move assignable, which is missing from the standard's requirements, but
    we should at least use move construction not copy construction.

    A similar problem exists for some other new C++17 numeric algos, but
    I'll fix the others in a subsequent commit.

    libstdc++-v3/ChangeLog:

            PR libstdc++/108236
            * include/pstl/glue_numeric_impl.h (exclusive_scan): Pass __init
            as rvalue.
            * include/pstl/numeric_impl.h (__brick_transform_scan): Do not
            write through __result until after reading through __first. Move
            __init into return value.
            (__pattern_transform_scan): Pass __init as rvalue.
            * include/std/numeric (exclusive_scan): Move construct instead
            of copy constructing.
            * testsuite/26_numerics/exclusive_scan/2.cc: New test.
            * testsuite/26_numerics/pstl/numeric_ops/108236.cc: New test.

    (cherry picked from commit cd107a6343c96c4ef26096e250d43a4a4211eced)

Reply via email to