[RFC PATCH] realloc: Make REALLOC_ZERO_BYTES_FREES into a tunable
Alejandro Colomar
alx@kernel.org
Thu Oct 24 16:58:17 GMT 2024
CC += Lundin
Hi Joseph,
On Thu, Oct 24, 2024 at 04:22:56PM GMT, Joseph Myers wrote:
> On Thu, 24 Oct 2024, Alejandro Colomar wrote:
>
> > The internet is on fire about ISO C23 making realloc(p,0) UB. I don't
>
> This sort of exaggerated claim seems like a great way to lose credibility
<https://langdev.stackexchange.com/questions/3286/what-was-the-rationale-for-making-reallocptr-0-have-ub-in-c23>
<https://stackoverflow.com/questions/78691087/reallocptr-0-in-c23-now-what>
<https://dl.acm.org/doi/pdf/10.1145/3588242>
<https://software.codidact.com/posts/289414/289415#answer-289415>
<https://software.codidact.com/posts/292694/292695#answer-292695>
> I think it would be a bad idea to relitigate the obsolescence and
> subsequent removal of realloc(p, 0),
Why do you think banning realloc(p,0) is better than fixing it? Yes, it
will be hard to fix it, but how is banning it better than fixing it?
Even if you say realloc() cannot be fixed without breaking other stuff,
we'd need realloc2() to be invented and fix this, even if it's just a
thin wrapper that does realloc(p,n?:1). There's a need for 0-sized
objects.
> just as it's a bad idea to relitigate
> the choice of name for _Lengthof.
That name was chosen by a small set of programmers, influenced by
programmers who don't even like C as their main language. I want to
avoid having another mistake from WG14 be a mess for the future.
Why should WG14's preference be more important than GCC's? Would you
mind surveying GCC and glibc maintainers and contributors on the topic?
Also, I can't even understand how a WG14 member gets offended by me
ignoring the results of his survey presented at his job to programmers
that explicitly say they hope to not have to program ever again in C, as
part of the survey comment. Their argument is that many other languages
--which don't have the ambiguity problem of null-terminated strings also
using length-- use length for this, so we should follow.
Please consider countof.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20241024/db710e26/attachment.sig>
More information about the Libc-alpha
mailing list