https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19831
--- Comment #24 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Marc Glisse from comment #16) > Some more transformations for the list: > > p = malloc (n); > memcpy (p, q, m); > free (q); > > ==> > > p = realloc (q, n); > > it isn't equivalent, in particular it could be slower if m is much smaller > than what q points to, but I think it should generally be safe and > profitable. Doing it without the memcpy is more questionable. This is also https://github.com/llvm/llvm-project/issues/128587 .