memcpy(0x1, 0x1, 0) is a well-defined no-op even when you don't have 0x1 in your address space.
Why handle 0x0 differently?
Why handle 0x0 differently?
Sure about that?
It really should be a no-op. The C and C++ standards are seriously broken in this respect, and compiler authors take advantage of this brokenness to get away with miscompiling programs that, to anyone with common sense, are fine.
Not as mechanism that can cause serious bugs, when the compiler can statically prove length argument to be 0 and you can have NULL arguments as input.
Calls to memcpy with zero length are definitely not uncommon. Macros are an obvious way, but it's worse. All you need is a data flow where compiler can statically prove that all paths lead to zero length argument.
I have to agree it's very scary that memcpy(NULL, NULL, 0) is undefined.