[Bug middle-end/32667] block copy with exact overlap is expanded as memcpy

post+gcc at ralfj dot de gcc-bugzilla@gcc.gnu.org
Tue Nov 28 07:20:18 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667

--- Comment #52 from post+gcc at ralfj dot de ---
For the point discussed earlier with the `restrict` in the musl memcpy, I had
another look at the definition of `restrict` and it's not entirely clear to me
any more that there is UB here. The restrict rules only apply to objects that
are "also modified (by any means)". Now the question is, does "*X = *X" modify
the object? Is a write always a modification or only if the stores
representation changes or only if the stored value changes?

If it requires a representation change, then "memcpy(x, x, n)" does not modify
anything, and hence there is no UB from "restrict".


More information about the Gcc-bugs mailing list