From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D8AE3387088C; Tue, 23 Feb 2021 11:43:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8AE3387088C From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/99117] [9/10/11 Regression] cannot accumulate std::valarray Date: Tue, 23 Feb 2021 11:43:34 +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: rguenther at suse dot de 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 11:43:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99117 --- Comment #12 from rguenther at suse dot de --- On Tue, 23 Feb 2021, redi at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99117 >=20 > --- Comment #11 from Jonathan Wakely --- > So is Jakub wrong in comment 5 when he suggests that this should "lose" t= he > __restrict__ qualification? >=20 > _Tp* __p (__a._M_data); Yes. __p is clearly based on __a._M_data and thus it can be used to access data pointed to by the restrict qualified __a._M_data which in turn means we can, if we prove value equivalence, place the same restrictions on accesses via __p as we can on accesses via __a._M_data. It would be way more awkward implementation-wise if we couldn't do that. > Is there a better way to drop that qual so that we can assign something t= o the > elements of __a._M_data that aliases itself? >=20 > Presumably this would be guaranteed to work? >=20 > _Tp* __p (__a._M_data); > for (size_t __i =3D 0; __i < __n; ++__i, ++__p) > { > _Tp __tmp =3D __e[__i]; > *__p =3D __tmp; > } That's no different. There's no way to lose restrict qualification but to obfuscate the code in a way to make the compiler not see the "based-on" relation of __a._M_data and the pointer used to=20 access the data. Passing __a by reference should also run into limitations of points-to analysis but I guess it would be an ABI change.=