From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EC6223842431; Tue, 16 Feb 2021 10:41:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC6223842431 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99117] [9/10/11 Regression] cannot accumulate std::valarray Date: Tue, 16 Feb 2021 10:41:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: needs-reduction, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 9.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2021 10:41:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99117 --- Comment #3 from Jonathan Wakely --- Regression started with r260318 tree-ssa-sccvn.c (vn_reference_lookup_3): Improve memset handling. 2018-05-17 Richard Biener * tree-ssa-sccvn.c (vn_reference_lookup_3): Improve memset handli= ng. * gcc.dg/tree-ssa/ssa-fre-63.c: New testcase. From-SVN: r260318 The testcase can be reduced to: #include #include #include int main() { std::vector> v =3D {{1,1}, {2,2}}; std::valarray sum(2); for (const auto& e : v) sum =3D sum + e; assert(sum[0]=3D=3D3); assert(sum[1]=3D=3D3); } This is what std::accumulate does, but it works as expected if you do: for (const auto& e : v) sum +=3D e; I'm not sure if sum =3D sum + e is valid, due to the aliasing rules of vala= rray. (the test passes if you use an array of valarray instead of std::vector, or pointers to valarrays instead of vector iterators, I'm not sure why)=