https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104722
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > I think this code is undefined as the order of the addition is not specified > for std::accumulate It is specified for std::accumulate, but the _GLIBCXX_PARALLEL mode breaks the guarantees by performing the additions in parallel, so not in the same order. The parallel mode was an experiment that will be removed from libstdc++ at some point. You might want to try the C++17 parallel algos instead, or just accept that parallel mode evaluates the algorithm differently (that's the whole point - it breaks the work into chunks to be evaluated in multiple threads).