The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Clem Cole <clemc@ccc.com>
To: Doug McIlroy <doug@cs.dartmouth.edu>
Cc: The Eunuchs Hysterical Society <tuhs@tuhs.org>
Subject: Re: [TUHS] reviving a bit of WWB
Date: Sun, 20 Sep 2020 18:13:46 -0400	[thread overview]
Message-ID: <CAC20D2Mxf6vwDDd2g7cvod8uBihH50htaAgsiXYJ7zvZ_NsJjQ@mail.gmail.com> (raw)
In-Reply-To: <202009202057.08KKvxAu141367@tahoe.cs.dartmouth.edu>

[-- Attachment #1: Type: text/plain, Size: 2360 bytes --]

On Sun, Sep 20, 2020 at 4:58 PM Doug McIlroy <doug@cs.dartmouth.edu> 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 <stddef.h> (and other headers) as a null
   pointer constant; see 7.19.
   3.



....
ISO/IEC 9899:2017 Section 7.19 *Common definitions <stddef,h>*
....

   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 <https://www.gimpel.com/about.html> (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.

: .

[-- Attachment #2: Type: text/html, Size: 6521 bytes --]

  reply	other threads:[~2020-09-20 22:14 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-19  1:51 Doug McIlroy
2020-09-20 18:42 ` arnold
2020-09-20 19:28   ` Will Senn
2020-09-20 20:12     ` Steve Nickolas
2020-09-20 20:26       ` Doug McIlroy
2020-09-20 20:57         ` Doug McIlroy
2020-09-20 22:13           ` Clem Cole [this message]
2020-09-21 20:43             ` Steffen Nurpmeso
2020-09-20 20:58         ` Steve Nickolas
2020-09-20 21:33           ` Brantley Coile
2020-10-07  5:43             ` scj
2020-09-20 21:35           ` John Cowan
2021-02-02 23:08             ` Greg A. Woods
2021-02-02 23:47               ` Larry McVoy
2021-02-03  0:11                 ` Dave Horsfall
2021-02-03  0:19                   ` Larry McVoy
2021-02-03  2:04                     ` Richard Salz
2021-02-03  3:32                       ` Dave Horsfall
2021-02-03  4:32                         ` M Douglas McIlroy
2021-02-03 11:27                           ` Peter Jeremy via TUHS
2021-02-03 20:09                             ` Dave Horsfall
2021-02-03 20:13                               ` Niklas Karlsson
2021-02-03 23:46                               ` Tom Lyon
2021-02-03 22:19                           ` Dave Horsfall
2021-02-03 22:55                             ` M Douglas McIlroy
2020-09-20 22:15           ` Clem Cole
2020-09-20 22:47             ` John Cowan
2020-09-21 20:48               ` Steffen Nurpmeso
2020-09-21 20:46           ` Steffen Nurpmeso
2020-09-24  2:25       ` Dave Horsfall
2020-09-24  2:33         ` Clem Cole
2020-09-25  0:18           ` [TUHS] One's complement (was: reviving a bit of WWB) Greg 'groggy' Lehey
2020-09-25  0:22             ` Warner Losh
2020-09-25  1:39               ` John Cowan
2020-09-27  5:54           ` [TUHS] reviving a bit of WWB Dave Horsfall
2020-09-24 17:19         ` Paul Winalski
2020-09-24 18:17           ` John Cowan
2020-10-07  5:47   ` scj
2020-10-07  9:20     ` arnold
2020-10-08  0:27     ` Dave Horsfall
2020-10-08  3:08       ` John Cowan
2020-09-20 22:51 Norman Wilson
2020-09-20 23:00 Norman Wilson
2020-09-20 23:53 ` Clem Cole
2020-09-21  0:00   ` Clem Cole
2020-09-21  2:24     ` John Cowan
2020-09-21  0:09   ` Warner Losh
2020-09-21  1:05     ` Clem Cole
2020-09-21  5:55     ` Steve Nickolas
2020-09-21  5:59       ` Warner Losh
2020-09-21 18:40         ` Paul Winalski
2020-09-21 19:56           ` Dan Cross
2020-09-21 20:50       ` John Cowan
2020-09-21 21:22         ` Rob Pike
2020-09-21 21:57           ` Clem Cole
2020-09-21 23:56             ` John Cowan
2020-09-22  0:54               ` Richard Salz
2020-09-21 21:39         ` Steve Nickolas
2020-09-25 14:19 Doug McIlroy
2020-09-28 17:35 ` Angelo Papenhoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAC20D2Mxf6vwDDd2g7cvod8uBihH50htaAgsiXYJ7zvZ_NsJjQ@mail.gmail.com \
    --to=clemc@ccc.com \
    --cc=doug@cs.dartmouth.edu \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).