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_INVALID,DKIM_SIGNED, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23015 invoked from network); 20 Sep 2020 22:14:53 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 20 Sep 2020 22:14:53 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 10356940FD; Mon, 21 Sep 2020 08:14:51 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 110DB94483; Mon, 21 Sep 2020 08:14:17 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ccc.com header.i=@ccc.com header.b="WT1lYVRB"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id D394693F5B; Mon, 21 Sep 2020 08:14:13 +1000 (AEST) Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by minnie.tuhs.org (Postfix) with ESMTPS id 3746D93F0F for ; Mon, 21 Sep 2020 08:14:13 +1000 (AEST) Received: by mail-qt1-f173.google.com with SMTP id e7so10684715qtj.11 for ; Sun, 20 Sep 2020 15:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccc.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9oa+WIv2BYrUiQA7BJjyzfvgf2J+KCUQrn3PIamR6hY=; b=WT1lYVRB3BoAP4ZTBD6fxQxDwmursNxtdnNbBZbtT3hesJG/WaJyuhqcc9hjJhFmqj 4BguBGBNfFvJcqrFFQS56oHm/J0SpwqRG3kPccBxeM/KUztwtD09zswKDhcRWJBWQn7J LBN+NDfbzt5STQ2t4ENGwxca/Dyy4zZeGPH6o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9oa+WIv2BYrUiQA7BJjyzfvgf2J+KCUQrn3PIamR6hY=; b=eKXTz0g+tU55cYx+rCeQA1Soa0mUcJih5nSZAYl733zI8XFqm7x+n/pm6P4UkatLfq uMGO0GWpdBEPNcI3hNeA8NUMoFYJ+ctRB6W49MdTkFCpEP+CRHDo3qS4VIpjlmn4v7c9 /61w0oEWMR1JppFwI3idD8sPXQlHyuY7lhGWbOj53N1+0NG9BXNfwStanTFCIvHuSjHa Atd53YWTZ3tswMc1E6zfVNeFIWqkUw5vHL34wqnB8mf/BpTvYFTohftnmSIx5JWXJovf m8tirRrxm/jmvyKqhrCWF19CVphn/tWsa/BseoFKrZxfI1H07JNkR8bbotl11O2eN/v/ VZxA== X-Gm-Message-State: AOAM531bIM6kV8HNsN0/POMx6xRJRLzAqtd0xBNaZiIyAjiYLRpPUtZC WV2ZTHoD8vFdJY+hQkjbv5dWA1ts1ENBo85KHtpvDg== X-Google-Smtp-Source: ABdhPJz/A7YLCfcEv1Wbd6cmLA4AEUDlbDJKmSDOf1PudCoJjofUt5ewOUr+6ISz/MoNhH+AdUeTA7Ko0fgFGMifWZY= X-Received: by 2002:ac8:7219:: with SMTP id a25mr44699508qtp.4.1600640052204; Sun, 20 Sep 2020 15:14:12 -0700 (PDT) MIME-Version: 1.0 References: <202009190151.08J1pYnb066792@tahoe.cs.dartmouth.edu> <202009201842.08KIgn2f022401@freefriends.org> <04211470-AD63-452A-A0BB-6A7A6FD85AAE@gmail.com> <202009202026.08KKQ2x6137303@tahoe.cs.dartmouth.edu> <202009202057.08KKvxAu141367@tahoe.cs.dartmouth.edu> In-Reply-To: <202009202057.08KKvxAu141367@tahoe.cs.dartmouth.edu> From: Clem Cole Date: Sun, 20 Sep 2020 18:13:46 -0400 Message-ID: To: Doug McIlroy Content-Type: multipart/alternative; boundary="000000000000b9ab1105afc60d1f" Subject: Re: [TUHS] reviving a bit of WWB X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --000000000000b9ab1105afc60d1f Content-Type: text/plain; charset="UTF-8" On Sun, Sep 20, 2020 at 4:58 PM Doug McIlroy wrote: > > To put it more strongly. this is not a legal C source file. > char *s = NULL; > But this is. > char *s = 0; > Hmmm ... Doug - As the risk of playing language lawyer here, I'm going to argue that between sections 6.3.2.3 and 7.19 the first is legal. Cut/pasted from my cope of the 2017 standard (I don't think this has changed in later drafts): ISO/IEC 9899:2017 Section 6.3.2.3 *Pointers* *....* 1. An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.67) If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function. 2. 67)The macro NULL is defined in (and other headers) as a null pointer constant; see 7.19. 3. .... ISO/IEC 9899:2017 Section 7.19 *Common definitions * .... 1. The macros are NULL which expands to an implementation-defined null pointer constant; For whatever its worth, in a number of common coding standards where I have worked, have always required that when NULL was used, it was always cast first to the actual data type. Yes, this is verbose, but it means that a casual reader sees the type and in particularly in a commerical SW development setting, that is money in the bank from a maintence standpoint -- IIRC Gimpel's flexelint (which IMO oppinion was always the best lint around), has a switch that will force that behavior. As I understand it, the idea behind -Wall *et al*, is that if we can get code to be 'flexelint clean' the number of latent bugs drops dramatically. This is particularly true when dealing with code that started be written on a system with one word or pointer size and now needs to run elsewhere; which is a common issue commerical ISVs live a great deal [this is a codified in the 10th of Henry's commandments: Thou shalt foreswear, renounce, and abjure the vile heresy which claimeth that ``All the world's a VAX'', and have no commerce with the benighted heathens who cling to this barbarous belief, that the days of thy program may be long even though the days of thy current machine be short. : . --000000000000b9ab1105afc60d1f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sun, Sep 20, 2020 at 4:58= PM Doug McIlroy <doug@cs.dartm= outh.edu> wrote:

To put it more strongly. this is not a legal C source file.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *s =3D NULL;
But this is.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *s =3D 0;

Hmmm ...=C2=A0 Doug - As the risk of playing language la= wyer here, I'm going to argue that between sections 6.3.2.3 and 7.19 th= e first is legal.=C2=A0 =C2=A0Cut/pasted from my cope of the 2017 standard = (I don't think this has changed in later drafts):
=
ISO/IEC 9899:2017 Section 6.3.2.3 Pointers= =C2=A0
= ....
=09 =09
  1. An intege= r constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.67) If a null pointer constant is converted to a pointer type, = the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to = any object or function.=C2=A0

  2. 67)The macro NULL is defined in <stddef.h> (and other headers) as a null pointer = constant; see 7.19.=C2=A0


....
ISO/IEC 9899:2017=C2=A0<= /span>Section 7.19=C2=A0Common definitions <stddef,h>
....=C2=A0
  1. The macro= s are

    NULL

    which exp= ands to an implementation-defined null pointer constant;=C2=A0

For whatever its worth, in a = number of common coding standards where I have worked, have always=C2=A0req= uired that when NULL was used, it was always cast first to the actual data = type.=C2=A0 Yes, this is verbose, but it means that a casual reader sees th= e type and in particularly in a commerical=C2=A0SW development setting, tha= t is money in the bank from a maintence standpoint --=C2=A0 IIRC Gimpel's flexelint (which IMO o= ppinion=C2=A0was always the best lint around), has a switch that will force= that behavior.=C2=A0=C2=A0

= As I understand it, the=C2=A0idea behind -Wall et al, is that if we can get code to be 'flexelint clean&#= 39; the number of latent bugs drops dramatically.=C2=A0 This is particularl= y true when dealing with code that started be written on a system with one = word or pointer size and now needs to run elsewhere; which is a common issu= e commerical ISVs live=C2=A0a=C2=A0great deal [this is a codified in the 10= th of Henry's commandments:

Thou s= halt foreswear, renounce, and abjure the vile heresy which claimeth that ``= All the world's a VAX'', and have no commerce with the benighte= d heathens who cling to this barbarous belief, that the days of thy program= may be long even though the days of thy current machine be short.

: .=C2=A0<= /div>
--000000000000b9ab1105afc60d1f--