gcc/libstdc++-v3/testsuite/26_numerics/valarray
Jonathan Wakely b58f0e5216 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.
2024-02-15 11:43:21 +00:00
..
requirements Update copyright years. 2024-01-03 12:19:35 +01:00
27867.cc Update copyright years. 2024-01-03 12:19:35 +01:00
28277.cc Update copyright years. 2024-01-03 12:19:35 +01:00
30416.cc Update copyright years. 2024-01-03 12:19:35 +01:00
33084.cc Update copyright years. 2024-01-03 12:19:35 +01:00
40691.cc Update copyright years. 2024-01-03 12:19:35 +01:00
69116.cc Update copyright years. 2024-01-03 12:19:35 +01:00
83860.cc Update copyright years. 2024-01-03 12:19:35 +01:00
87641.cc Update copyright years. 2024-01-03 12:19:35 +01:00
95592.cc Update copyright years. 2024-01-03 12:19:35 +01:00
99117.cc libstdc++: Avoid aliasing violation in std::valarray [PR99117] 2024-02-15 11:43:21 +00:00
103022.cc
algo.cc Update copyright years. 2024-01-03 12:19:35 +01:00
binary_closure.cc
const_bracket.cc Update copyright years. 2024-01-03 12:19:35 +01:00
deduction.cc Update copyright years. 2024-01-03 12:19:35 +01:00
dr543.cc Update copyright years. 2024-01-03 12:19:35 +01:00
dr630-1.cc Update copyright years. 2024-01-03 12:19:35 +01:00
dr630-2.cc Update copyright years. 2024-01-03 12:19:35 +01:00
dr630-3.cc Update copyright years. 2024-01-03 12:19:35 +01:00
init-list.cc Update copyright years. 2024-01-03 12:19:35 +01:00
mask-1_neg.cc
mask-2_neg.cc
mask-3_neg.cc
mask-4_neg.cc
mask-5_neg.cc
mask-6_neg.cc
mask-7_neg.cc
mask-8_neg.cc
mask.cc
moveable.cc Update copyright years. 2024-01-03 12:19:35 +01:00
name_lookup.cc Update copyright years. 2024-01-03 12:19:35 +01:00
noexcept_move_construct.cc Update copyright years. 2024-01-03 12:19:35 +01:00
operators.cc Update copyright years. 2024-01-03 12:19:35 +01:00
range_access.cc Update copyright years. 2024-01-03 12:19:35 +01:00
range_access2.cc Update copyright years. 2024-01-03 12:19:35 +01:00
subset_assignment.cc Update copyright years. 2024-01-03 12:19:35 +01:00
swap.cc Update copyright years. 2024-01-03 12:19:35 +01:00
transcend.cc Update copyright years. 2024-01-03 12:19:35 +01:00