Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 20 Jul 2023 18:54:37 -0700
Organization: A noiseless patient Spider
Lines: 73
Message-ID: <86jzuuvxk2.fsf@linuxsc.com>
References: <20230713104558.553@kylheku.com> <871qh9zjke.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="2d78163bfb891e7187c96a580a5a5784"; logging-data="3116812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qGn+WTzqlrvNXywzvZ0RHfXvhaSbTLhk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:T2auWV2xBVk4BuPp+cGMskmirHE= sha1:VlU52Pm6BdkeroP8jkWkDFWQGoY=
Xref: csiph.com comp.lang.c:171003
Keith Thompson writes:
> Po Lu writes:
>
>> kalevi@kolttonen.fi (Kalevi Kolttonen) writes:
>>
>>> Po Lu wrote:
>>>
>>>> kalevi@kolttonen.fi (Kalevi Kolttonen) writes:
>>>>
>>>>> No. Lots of C programs are quite portable. That includes e.g. Linux
>>>>> kernel, BSD kernels, PostgreSQL, Apache, Postfix, and many,
>>>>> many other Unix daemons. PostgreSQL runs not only on Unix
>>>>> but even on Windows. Possibly OpenLDAP does, too.
>>>>
>>>> Yet none of these programs strictly conform to a Standard. They are
>>>> more or less conforming programs, meaning that they are acceptable
>>>> to
>>>> the C implementations that they have been ported to.
>>>
>>> You could well be right. But invoking UB is something so evil
>>> that no C or C++ program must ever do it, meaning that the
>>> programmers must know enough to avoid it.
>>>
>>> Since you seem to be confident about your claim, is it possible
>>> for you to describe what aspects of Postfix are non-corforming
>>> C code?
>>
>> Not strictly conforming? Easy: any code that assumes char is 8 bits
>> wide, or that int can hold values larger than 32766.
>
> 32767.
>
> Or any code whose behavior depends on those things. For example, this:
>
> #include
> #include
> int main(void) {
> printf("%d\n", INT_MAX);
> }
>
> is in a sense 100% portable to any hosted implementation, but it's not
> strictly conforming.
>
>>> Speaking of MTAs, Sendmail was/is portable enough so that it runs
>>> on practically every modern and not-so-modern UNIX. This being
>>> the case, one could assume that its C code must be very
>>> standards compliant, no? What do you think?
>>
>> What exactly is ``standards compliance''?
>> Mere conformance, or strict conformance?
>
> A "conforming program" is one that is acceptable to a conforming
> implementation -- an almost absurdly weak condition. If there's a C
> implementation that accepts Fortran programs as an extension (after
> issuing any required diagnostic), then a Forgran program is a
> "conforming program", though I doubt that the authors meant the
> definition to be quite that loose.
>
> But I think there's an intermediate level of conformance: a "correct
> program".
>
> A program that is correct in all other aspects, operating on correct
> data, containing unspecified behavior shall be a correct program and
> act in accordance with 5.1.2.3.
>
> (This in section 4 of the ISO C standard.)
Note that a "correct program" can include programs that depend on
unspecified behavior, and on implementation-defined behavior, and
on implementation-specific extensions covering particular cases
of undefined behavior. There is nothing "incorrect" about
depending on extensions that cover areas of undefined behavior.