https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99117
Bug ID: 99117
Summary: cannot accumulate std::valarray
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yasui at icepp dot s.u-tokyo.ac.jp
Target Milestone: ---
Created attachment 50193
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50193&action=edit
source file
The result of the summation of the std::valarrays by std::accumulate is
improper when compiling with -O2.
It works properly with -O1.
option:
g++ -std=c++2a -Wall -Wextra -O2 source.cpp
In the source file, it calculates (1,1) + (2,2) = (3,3).
The expected result is outputting nothing.
If compiling with -O2, following message is shown:
a.out: source.cpp:10: int main(): Assertion `sum[0]==3' failed.