diff --git a/clang/docs/Toolchain.rst b/clang/docs/Toolchain.rst --- a/clang/docs/Toolchain.rst +++ b/clang/docs/Toolchain.rst @@ -276,6 +276,19 @@ `C standard library `_ implementations. +Clang and LLVM make some assumptions about the behavior of the C standard +library beyond those required by the C standard: + +* ``memcpy(p, q, 0)`` and ``memmove(p, q, 0)`` are expected to have no effect, + even if ``p`` or ``q`` is a null or otherwise-invalid (but correctly-aligned) + pointer. +* ``memcpy(p, p, n)`` is expected to leave the contents of the memory pointed + to by ``p`` unchanged, but may perform (redundant) loads and stores through + the ``n`` bytes pointed to by ``p``. + +C standard library implementations that do not guarantee these properties +incompatible with Clang and LLVM (and with several other major compilers). + C++ ABI library ---------------