From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20518 invoked from network); 13 Mar 2023 20:27:46 -0000 Received: from minnie.tuhs.org (2600:3c01:e000:146::1) by inbox.vuxu.org with ESMTPUTF8; 13 Mar 2023 20:27:46 -0000 Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id AC475412FD; Tue, 14 Mar 2023 06:27:39 +1000 (AEST) Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by minnie.tuhs.org (Postfix) with ESMTPS id 231C441298 for ; Tue, 14 Mar 2023 06:27:33 +1000 (AEST) Received: by mail-lf1-x131.google.com with SMTP id s22so17290377lfi.9 for ; Mon, 13 Mar 2023 13:27:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678739251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6uWB5bgWFPdUhpRQlye7H2jwNWkkziUbOV5MKYaphbg=; b=XrY/oPJSeH3fWeDl+Q8LqXKIL6s1PiUl8jP5nTIxxURPQgrVfKuZLwbgDAFZ13JQ6K u/p+V2b5JwKI8xTJ9hI9dofng7YKEvlOK79eAdprK0CazSHa+bnaaqKf7U8THP1SpIru nl2KLYnQyTt5LcFg8DLx11VC9tNZAesg66ET87t0h9dB7CMctuf139XRJMkK6LmI6ZCJ mK0Y3OePtXG2dYpx4BmYqf2jYMgsEEpmzlkG3S+6pqzpFwbuQFjkJapnnea92CrI8XMx ko+jEZQgX3+w4PQUkAFknOTTzk9Zo9vFZQI9eVo1nxg8GIjZrfRd5YzV74JFoTovuwZg MaFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678739251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6uWB5bgWFPdUhpRQlye7H2jwNWkkziUbOV5MKYaphbg=; b=vFZQ8ow1z+ReExDbzNN7K1nJiDgP11q6Mw3AsOPUX9rHMbTvkuDP/8CNMEstXqndjR S+sflkDfWU8tYx2RabaP982qiG/3Tyy4dpOr0esVGlFn+iK0OosEpvn157Jl2QdFqSuE n1qR0skw3C3fvrD06f+/Bi2orX1socPBxL3FifIRCTweSWHiERp0Xd2Nv8oxBNiezjOw aaMf4nyMZYYAsZZQhnL3OXfc4HlAg6XajjpJrt2wtbFIfrKnNr1RKiNsAvAPXiuAM6R0 X9A8rX9Wi/XhLyoLVkBWZ6Ifcof/bKtHulGTp9sJwUh/XMm1/roiSa9kLPwKT62fCd/Q FeNw== X-Gm-Message-State: AO0yUKWJvfPp+D3ABHyzC67vJIQRX5Ma5EJ3MyGv81sIgMI4XQDWAtUd uWP3RHPnbyMLm4k5U5gw1eZAUQR47TYQGZotOmw9+3db X-Google-Smtp-Source: AK7set9MZ/kVUxWmCVY8D2HUffgNxz8AYabByRyKbfScnIitZ7tQdC7zkQupCEszi8zs+4u4dMYTtlfGytBl38Hl8wk= X-Received: by 2002:ac2:5963:0:b0:4d5:ca43:7049 with SMTP id h3-20020ac25963000000b004d5ca437049mr10871140lfp.12.1678739251051; Mon, 13 Mar 2023 13:27:31 -0700 (PDT) MIME-Version: 1.0 References: <20230310113708.AD55518C080@mercury.lcs.mit.edu> In-Reply-To: From: Dan Cross Date: Mon, 13 Mar 2023 16:26:54 -0400 Message-ID: To: Steve Nickolas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LG6O6DBPPBYM7OM64I5C5TJTWPL5CXT5 X-Message-ID-Hash: LG6O6DBPPBYM7OM64I5C5TJTWPL5CXT5 X-MailFrom: crossd@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: TUHS X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: [TUHS]: C dialects (was: I can't drive 55: "GOTO considered harmful" 55th anniversary) List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, Mar 13, 2023 at 3:16=E2=80=AFPM Steve Nickolas = wrote: > On Mon, 13 Mar 2023, Clem Cole wrote: > > Frankly, I'd probably rather see ISO drop a bunch of the stuff they are= now > > requiring and fall back at least to K&R2 -- keep it simple. The truth i= s > > that we still use the language today is that K&R2 C was then (and still= is) > > good enough and got (gets) the job done extremely well. Overall, I'm= not > > sure all the new "features" have added all that much. > > C99 did introduce one thing I use: > > Beyond that, I still code strict C89. I simply treat the language itself > as ossified. I also still make assumptions about the compiler that might > not still be true, so for example > > unsigned short a; > unsigned char b; > > b=3D0xFF; > a=3Db<<8; > > I expect to return 0 even though the logical answer is 0xFF00, I don't know why one would expect that. `b` will be promoted to (signed!!) `int` before the shift, and then the result of that assigned to `a`, wrapping as needed to fit into the `unsigned short`; on most reasonable systems the UB gods won't be angered. OTOH, `uint16_t mul(uint16_t a, uint16_t b) { return a * b; }` is a UB minefield on most systems. > and I > _always_ code it like this: > > b=3D0xFF; > a=3Db; > a<<=3D8; Curiously, this will be subject to the same type promotion rules as the original. > or alternatively > > b=3D0xFF; > a=3D((unsigned short) b)<<8; As will this. In fact, the cast here is completely superfluous; the shift will still be done using after promotion to signed int. > and there's other defensive stuff I do. I honestly don't see the point i= n > the other changes to the language and feel they take C away from what it > has always been. I think an issue is that there is what people _think_ C does, and what C _actually_ does, and the two are often discordant; this is why I think you see people tweaking compiler options to create a dialect that's reasonable to program in: given a large-enough code base, you inevitably end up with a very peculiar dialect, which compounds the problem. For example, I'm quite sure that the C dialect that Linux uses is not the same as the C that Windows uses, and so on. The compiler writers now seem very much of the mind where you point this out and they look at you and say, "tough." - Dan C.