[v2] malloc.3: Clarify realloc(3) standards conformance
Eric Blake
eblake@redhat.com
Thu Jun 19 18:50:01 GMT 2025
On Thu, Jun 19, 2025 at 01:42:38PM -0500, Eric Blake wrote:
> > +
> > + The glibc implementation of realloc() is not consistent with
> > + that, and as a consequence, it is dangerous to call
> > + realloc(p, 0) in glibc.
>
> More importantly, with C23 making it undefined behavior, it is
> dangerous to call realloc(non_null, 0) in ANY libc, ever. Regardless
> of whether glibc documents semantics that comply (or don't comply)
> with older standards.
That is, unless a future revision of POSIX adds intentional <CX>
shading to state that on POSIX platforms, realloc(non_null, 0) has
well-defined behavior, and therefore making it usable on POSIX systems
even if not appropriate for generic C systems.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
More information about the Libc-alpha
mailing list