diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-02-08 13:59:42 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-02-15 11:43:21 +0000 |
commit | b58f0e5216a3053486e7f1aa96c3f2443b14d630 (patch) | |
tree | 753183dc3948c3f5338c7fe492915d8a72584bb1 /gcc | |
parent | 4d6513f80bd2349559ec7e3844cf096cdb103e9a (diff) | |
download | gcc-b58f0e5216a3053486e7f1aa96c3f2443b14d630.zip gcc-b58f0e5216a3053486e7f1aa96c3f2443b14d630.tar.gz gcc-b58f0e5216a3053486e7f1aa96c3f2443b14d630.tar.bz2 |
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=(const _Expr&)):
Use loop to copy instead of __valarray_copy with _Array.
* testsuite/26_numerics/valarray/99117.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions