Thread (18 messages) 18 messages, 6 authors, 2025-06-20

Re: [v2] malloc.3: Clarify realloc(3) standards conformance

From: Eric Blake <hidden>
Date: 2025-06-19 18:50:13

On Thu, Jun 19, 2025 at 01:42:38PM -0500, Eric Blake wrote:
quoted
+
+       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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help