| 
  | 
Message-ID: <17610231.87JKscXggJ@tjmaciei-mobl5>
Date: Sat, 01 Nov 2025 07:55:06 -0700
From: Thiago Macieira <thiago@...ieira.org>
To: musl@...ts.openwall.com, Thorsten Glaser <tg@...bsd.de>
Cc: Alejandro Colomar <alx@...nel.org>, libc-alpha@...rceware.org,
 "A. Wilcox" <AWilcox@...cox-tech.com>,
 Lénárd Szolnoki <cpp@...ardszolnoki.com>,
 Collin Funk <collin.funk1@...il.com>,
 Arthur O'Dwyer <arthur.j.odwyer@...il.com>,
 Jonathan Wakely <jwakely@...hat.com>, "Paul E. McKenney" <paulmck@...nel.org>
Subject: Re: Re: realloci(): A realloc() variant that works in-place
On Saturday, 1 November 2025 06:38:41 Pacific Daylight Time Thorsten Glaser 
wrote:
> Paul Eggert dixit:
> > You're right I'm not saying that. All I'm saying is that when
> > R=realloc(P,N) succeeds, you can assume that you can adjust old
> > pointers into the object addressed by P by adding R-P to them. The C
> > standard says this results in undefined behavior; all that we need to
> > do is fix the C standard to say it's well-defined (because it is on
> > practical platforms).
> 
> That won’t fix old standard versions retroactively though.
> 
> You can already do this now by casting the old pointer to
> ptraddr_t (ifdef __CHERI__) / uintptr_t (else) before the
> realloc and the new one afterwards for comparison and the
> arithmetic.
Strictly speaking, you need core language changes in both C and C++ to make 
the the arithmetic in question valid, instead of UB. I wouldn't hold my hopes 
up, in spite of just "works everywhere".
Anyway, I now understand Paul's proposal. It is orthogonal to realloci(). I am 
not sure if I would support it, but I wouldn't oppose it in *addition* to 
realloci(). I would definitely oppose it if it is *instead of* realloci().
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Download attachment "signature.asc" of type "application/pgp-signature" (871 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.