[TUHS] Minimum Array Sizes in 16 bit C (was Maximum)
Dan Cross
crossd at gmail.com
Mon Sep 30 22:15:03 AEST 2024
On Sat, Sep 28, 2024 at 7:37 PM Warner Losh <imp at bsdimp.com> wrote:
> On Sat, Sep 28, 2024, 5:05 PM Rob Pike <robpike at gmail.com> wrote:
>> I wrote a letter to the ANSI C (1989) committee.
>>
>> Please allow malloc(0).
>> Please allow zero-length arrays.
>>
>> I got two letters back, saying that malloc(0) is illegal because zero-length arrays are illegal, and the other vice versa.
>>
>> I fumed.
>
> And now we have zero length arrays an UB malloc(0).
I'm late to this; I know. But I wonder if perhaps you meant realloc(0,
p) being made UB in C23? This caused something of a kerfuffle, perhaps
exemplified by an incredibly poorly written "article" in ACM Queue.
I asked Jean-Heyd Meneide why this was done, and he broke it down for
me (the gist of it being, "it was the least-bad of a bunch of bad
options..."). The take from the C standards committee was actually
very reasonable, given the constraints they are forced to live under
nowadays, even if some of the rank and file were infuriated. But I
think the overall situation is illustrative of the sort of dynamic Rob
alluded to. The motivations of C compiler writers and programmers have
diverged; a great frustration for me is that, despite its origins as a
language meant to support systems programming and operation systems
implementation, compiler writers these days seem almost antagonistic
to that use. Linux, for instance, is not written in "C" so much as
"Linux C", which is a dialect of the language selected by selectively
setting compiler flags until some set of reasonable presets tames it
enough to be useful.
- Dan C.
More information about the TUHS
mailing list