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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Thu Oct 18 19:38:56 2018
New Revision: 265285

URL: https://gcc.gnu.org/viewcvs?rev=265285&root=gcc&view=rev
Log:
PR libstdc++/87641 correctly initialize accumulator in valarray::sum()

Use the value of the first element as the initial value of the
__valarray_sum accumulator. Value-initialization might not create the
additive identity for the value type.

        PR libstdc++/87641
        * include/bits/valarray_array.h (__valarray_sum): Use first element
        to initialize accumulator instead of value-initializing it.
        * testsuite/26_numerics/valarray/87641.cc: New test.

Added:
    branches/gcc-7-branch/libstdc++-v3/testsuite/26_numerics/valarray/87641.cc
Modified:
    branches/gcc-7-branch/libstdc++-v3/ChangeLog
    branches/gcc-7-branch/libstdc++-v3/include/bits/valarray_array.h

Reply via email to