| 
  | 
Message-ID: <294157776.ifERbkFSEj@tjmaciei-mobl5>
Date: Fri, 31 Oct 2025 09:02:42 -0700
From: Thiago Macieira <thiago@...ieira.org>
To: Alejandro Colomar <alx@...nel.org>, Thorsten Glaser <tg@...bsd.de>
Cc: libc-alpha@...rceware.org, musl@...ts.openwall.com,
 "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>, Alejandro Colomar <alx@...nel.org>
Subject: Re: Re: realloci(): A realloc() variant that works in-place
On Friday, 31 October 2025 08:45:09 Pacific Daylight Time Thorsten Glaser 
wrote:
> >In C, I've sometimes seen programmers trying to check if realloc(3)
> >moved or not, to skip some work.  That's a micro-optimization that I've
> >never written myself, so I won't defend it.  But for some reason, some
> >programmers keep wanting to do it.
> 
> Huh. That one if is probably more effort than just doing the
> arithmetics always… if it’s not actually UB…
The conclusion among C++ developers is that using the previous pointer in any 
way is UB. Therefore, you simply cannot know if the area was moved or not.
-- 
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.