[musl] Re: realloci(): A realloc() variant that works in-place

Rich Felker dalias@libc.org
Mon Nov 10 15:11:35 GMT 2025


On Sun, Nov 09, 2025 at 06:47:54PM -0800, Paul Eggert wrote:
> On 2025-11-09 17:20, Rich Felker wrote:
> > The only way the lifetime of P does not end is if realloc returns a
> > null pointer indicating failure.
> 
> Yes, and my point was that Alejandro's summary of the situation (which you
> went along with) got this detail wrong. And once one gets this detail right
> (which static analyzers of course can do), that discredits the idea that
> static analyzers are so dumb that they can't handle conditional results from
> functions like realloc. On the contrary, static analyzers do that sort of
> thing routinely, and they could continue to do so if the standard were
> changed slightly in the direction I proposed.

It's not a "conditional result" unless the condition you mean is
failure to allocate. realloc *always frees the old object* on success.

Rich


More information about the Libc-alpha mailing list