[PATCH] D86993: Document Clang's expectations of the C standard library.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 1 17:10:58 PDT 2020
rsmith created this revision.
rsmith added reviewers: fhahn, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
rsmith requested review of this revision.
As suggested in https://reviews.llvm.org/D86815
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86993
Files:
clang/docs/Toolchain.rst
Index: clang/docs/Toolchain.rst
===================================================================
--- clang/docs/Toolchain.rst
+++ clang/docs/Toolchain.rst
@@ -276,6 +276,19 @@
`C standard library <https://en.cppreference.com/w/c>`_
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
---------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86993.289328.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200902/6e9f244f/attachment.bin>
More information about the cfe-commits
mailing list