The chunkset_tpl comment allows negative dist (out - from) as long as
the length is smaller than the absolute value of dist (i.e. memory does
not overlap). However this case is currently broken in the RVV override
of CHUNKCOPY -- it compares dist (which is a ptrdiff_t, a value that
should be of the same size with size_t but signed) with the result of
sizeof (which is a size_t), and this triggers the implicit conversion
from signed to unsigned (thus losing negative values).
As it's promised to be not overlapping when dist is negative, just use a
gaint memcpy() call to copy everything.
Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
from += align;
len -= align;
ptrdiff_t dist = out - from;
- if (dist >= len) {
+ if (dist < 0 || dist >= len) {
memcpy(out, from, len);
out += len;
from += len;