From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 99A1C384F4A0; Thu, 15 Feb 2024 11:44:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99A1C384F4A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707997464; bh=o6N5UK2UJ4Xi85YmM2YK1FB6gVFr242ko71UtUF4lzI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IzFO/jI/c2kRwIOqiTDFXUueSSuefPSLTOc+3DFASfziFurURXG9B9XmxGYZHB84Q Us5EPWJHKQJg78NpzkwfNL/VSE84fTRMVoQkbZIbS7WDLCB3CfIgeC0ck4ULFod98O kyjcyU9K6MMpr2ZlRau3leNPCC0PlQ2E2KzRtIXo= From: "cvs-commit 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, 15 Feb 2024 11:44:18 +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: cvs-commit 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 #23 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:b58f0e5216a3053486e7f1aa96c3f2443b14d630 commit r14-9000-gb58f0e5216a3053486e7f1aa96c3f2443b14d630 Author: Jonathan Wakely Date: Thu Feb 8 13:59:42 2024 +0000 libstdc++: Avoid aliasing violation in std::valarray [PR99117] The call to __valarray_copy constructs an _Array object to refer to this->_M_data but that means that accesses to this->_M_data are through a restrict-qualified pointer. This leads to undefined behaviour when copying from an _Expr object that actually aliases this->_M_data. Replace the call to __valarray_copy with a plain loop. I think this removes the only use of that overload of __valarray_copy, so it could probably be removed. I haven't done that here. libstdc++-v3/ChangeLog: PR libstdc++/99117 * include/std/valarray (valarray::operator=3D(const _Expr&)): Use loop to copy instead of __valarray_copy with _Array. * testsuite/26_numerics/valarray/99117.cc: New test.=