From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CA154389852C; Tue, 23 Feb 2021 14:17:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA154389852C From: "jakub 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, 23 Feb 2021 14:17:26 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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, 23 Feb 2021 14:17:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99117 --- Comment #16 from Jakub Jelinek --- So perhaps (totally untested): --- libstdc++-v3/include/std/valarray.jj 2021-01-04 10:26:02.3669673= 42 +0100 +++ libstdc++-v3/include/std/valarray 2021-02-23 15:16:22.402688841 +0100 @@ -838,7 +838,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // _GLIBCXX_RESOLVE_LIB_DEFECTS // 630. arrays of valarray. if (_M_size =3D=3D __e.size()) - std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); + std::__valarray_copy(__e, _M_size, _M_data); else { if (_M_data) --- libstdc++-v3/include/bits/valarray_array.tcc.jj 2021-01-04 10:26:03.768951467 +0100 +++ libstdc++-v3/include/bits/valarray_array.tcc 2021-02-23 15:15:29.273282041 +0100 @@ -146,6 +146,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION *__p =3D __e[__i]; } + // Copy n consecutive elements of e into consecutive elements of p. + // I.e. p[i] =3D e[i]. p can alias what e uses. + template + void + __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Tp* __p) + { + for (size_t __i =3D 0; __i < __n; ++__i, ++__p) + *__p =3D __e[__i]; + } + // Copy n consecutive elements of e into elements of a using stride // s. I.e., a[0] =3D e[0], a[s] =3D e[1], a[2*s] =3D e[2]. template=