public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5772] middle-end/32667 - document cpymem and memcpy exact overlap requirement
@ 2023-11-23  8:32 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-11-23  8:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7758cb4b53e8a33642709402ce582f769eb9fd18

commit r14-5772-g7758cb4b53e8a33642709402ce582f769eb9fd18
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Nov 23 08:54:56 2023 +0100

    middle-end/32667 - document cpymem and memcpy exact overlap requirement
    
    The following amends the cpymem documentation to mention that exact
    overlap needs to be handled gracefully, also noting that the target
    runtime is expected to behave the same way where -ffreestanding
    docs mention the set of routines required.
    
            PR middle-end/32667
            * doc/md.texi (cpymem): Document that exact overlap of source
            and destination needs to work.
            * doc/standards.texi (ffreestanding): Mention memcpy is required
            to handle the exact overlap case.

Diff:
---
 gcc/doc/md.texi        | 5 +++--
 gcc/doc/standards.texi | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index df6725ffc9c..536ce997f01 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -6915,8 +6915,9 @@ individually copied data units in the block.
 
 The @code{cpymem@var{m}} patterns need not give special consideration
 to the possibility that the source and destination strings might
-overlap. These patterns are used to do inline expansion of
-@code{__builtin_memcpy}.
+overlap.  An exception is the case where source and destination are
+equal, this case needs to be handled correctly.
+These patterns are used to do inline expansion of @code{__builtin_memcpy}.
 
 @cindex @code{movmem@var{m}} instruction pattern
 @item @samp{movmem@var{m}}
diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi
index 4eb43f14f90..6eebb9426f3 100644
--- a/gcc/doc/standards.texi
+++ b/gcc/doc/standards.texi
@@ -184,7 +184,9 @@ GNU C library).  @xref{Standard Libraries,,Standard Libraries}.
 Most of the compiler support routines used by GCC are present in
 @file{libgcc}, but there are a few exceptions.  GCC requires the
 freestanding environment provide @code{memcpy}, @code{memmove},
-@code{memset} and @code{memcmp}.
+@code{memset} and @code{memcmp}.  Contrary to the standards
+covering @code{memcpy} GCC expects the case of an exact overlap
+of source and destination to work and not invoke undefined behavior.
 Finally, if @code{__builtin_trap} is used, and the target does
 not implement the @code{trap} pattern, then GCC emits a call
 to @code{abort}.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-23  8:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23  8:32 [gcc r14-5772] middle-end/32667 - document cpymem and memcpy exact overlap requirement Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).