On 20/09/19 07:08 +0200, François Dumont wrote:
I already realized that previous patch will be too controversial to be
accepted.
In this new version I just implement a real memmove in __memmove so
A real memmove doesn't just work backwards, it needs to detect any
overlaps and work forwards *or* backwards, as needed.
I think your change will break this case:
#include <algorithm>
constexpr int f(int i, int j, int k)
{
int arr[5] = { 0, 0, i, j, k };
std::move(arr+2, arr+5, arr);
return arr[0] + arr[1] + arr[2];
}
static_assert( f(1, 2, 3) == 6 );
This is valid because std::move only requires that the result iterator
is not in the input range, but it's OK for the two ranges to overlap.
I haven't tested it, but I think with your change the array will end
up containing {3, 2, 3, 2, 3} instead of {1, 2, 3, 2, 3}.