Path: csiph.com!news.swapon.de!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: "Catch-23: The New C Standard,Sets the World on Fire" by Terence Kelly with Special Guest Borer Yekai Pan
Date: Wed, 19 Jul 2023 08:56:07 -0700
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <86edl328vc.fsf@linuxsc.com>
References: <875yaa6sls.fsf@bsb.me.uk> <868rf563qh.fsf@linuxsc.com> <87355d576v.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="8c497607f8a118c6a9e414accc18c8f8"; logging-data="2338688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gKI4VVe/9fkjR0m2QVmNzOYC+owUsemM="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Gs+EXJGTFvZgQUAGzq3wBCy6qIk= sha1:2c1Ci673TFyO+GYPYl5OMBFhF6Y=
Xref: csiph.com comp.lang.c:170912
cross@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <87355d576v.fsf@bsb.me.uk>,
> Ben Bacarisse wrote:
>
>> Tim Rentsch writes:
>>
>>> [snip]
>>> Clearly if push() is called when N == SIZE_MAX (which is possible
>>> only if sizeof (int) == 1) then the code misbehaves. To me this
>>> eventuality is more like an unlikely corner case than it is an
>>> implementation assumption. Granted, the misbehavior can occur
>>> only on some implementations, but the problem is that the code is
>>> wrong, not that it has an implementation dependency. That said,
>>> I see now how this situation fits with what you said earlier
>>> mentioning "a puzzle" (although it still feels like the phrase
>>> "implementation assumptions" is more misdirection than it is
>>> something else).
>>
>> I wouldn't say that the code is wrong. It may never have been
>> written to be portable and there may even be a static assert or
>> some other test that checks the assumptions the programmer made.
>> At least that's how I see it.
>
> It was presented as _idiomatic_ and representative of an
> "exemplary pattern" (the authors words).
I believe you are misunderstanding what is being represented
here. The claim is not that the code in the three function
bodies is idiomatic and exemplary (which the paper itself makes
clear later in the "Drills" section). Rather it is that the
style of use of realloc() is idiomatic and exemplary, which
surely is the case for semantics of realloc() that is under
discussion.
> They put in a tiny hedge by saying it worked for systems
> with "zero-NULL" semantics, but it's clear they thought it
> widely applicable.
Certainly it /was/ applicable for at least the ten years between
the C89 standard and the C99 standard, and probably generally
applicable for at least several years on either side of that
range. As far as the expectations of the user community go,
probably it was perceived as being applicable until some time
between the C11 standard and the C17 standard.