From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D8DB13858403; Thu, 8 Feb 2024 21:35:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8DB13858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707428123; bh=pbWZ3LEP3UnJdGjDEWggHjwVuaTHeNKAVnfU1i+2gao=; h=From:To:Subject:Date:In-Reply-To:References:From; b=myPaUuk/DgZVZ4uPUqh3KVwnZMKLuRo7cZiJ/NBS+6RVhIzBjEXAmJTysN8wECJjS yF/5wzoMzBjZav/VsIIfYPvf1I0pC6HtRf9Sf2/d6SWYglzM4VzBJAa7B0xlksXo6G wm4p1yUkB55S6IIG7hSsU8NBH5s06/axergOKhMU= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99117] [11/12/13/14 Regression] cannot accumulate std::valarray Date: Thu, 08 Feb 2024 21:34:47 +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: 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: 11.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99117 --- Comment #22 from Jonathan Wakely --- Instead of adding yet another __valarray_copy overload, we can just not use= it: --- a/libstdc++-v3/include/std/valarray +++ b/libstdc++-v3/include/std/valarray @@ -840,7 +840,13 @@ _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)); + { + // Copy manually instead of using __valarray_copy, because __e mi= ght + // alias _M_data and the _Array param type of __valarray_copy uses + // restrict which doesn't allow aliasing. + for (size_t __i =3D 0; __i < _M_size; ++__i) + _M_data[__i] =3D __e[__i]; + } else { if (_M_data) That would actually allow us to remove that __valarray_copy overload, becau= se this is the only caller.=