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 18980 invoked from network); 20 Sep 2020 21:36:51 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 20 Sep 2020 21:36:51 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id EA4649CC1B; Mon, 21 Sep 2020 07:36:43 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 4AD679C772; Mon, 21 Sep 2020 07:36:09 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ccil-org.20150623.gappssmtp.com header.i=@ccil-org.20150623.gappssmtp.com header.b="sokTijfP"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id E096F940FD; Mon, 21 Sep 2020 07:36:05 +1000 (AEST) Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by minnie.tuhs.org (Postfix) with ESMTPS id DA20493F5B for ; Mon, 21 Sep 2020 07:36:03 +1000 (AEST) Received: by mail-qv1-f45.google.com with SMTP id cy2so6348896qvb.0 for ; Sun, 20 Sep 2020 14:36:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OMNQYew4VE3gTdl9Zp4fNI8s3nI+WY23h3dzUqZ/bOE=; b=sokTijfPSN9cCzUQDcWoVQh0eHZo9pNBDHW9GQ+HSbZMi6A+eNiGFl088pOdj7UKuF oM1Ogsv8UCtMuTIEMSpkGHjqUYVjUEZ+aVhyvlybqIudbnWEqo7Ggji0dMyaW+sRM9xZ IjE4tbXDemv7LbpVTyP9BZhP2TgPnRoVzSzBeN4R8jbT6EBI+vDCTFLQw4MsRu/DuaR+ eZxZpMphSUEJp21N5xa+QhCIIJhHNWiNLgX3FafHV9IBR6kcKm5s1BcPsQk8GAiWqvc3 Lp76GCyNfWlmkdwMjWTkjMHNbQkR+uFQOLayiR4hgoUjONjLSSlPc8L38kQbSS1DQ+gU QMMQ== 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=OMNQYew4VE3gTdl9Zp4fNI8s3nI+WY23h3dzUqZ/bOE=; b=VhuTjPK970gpVZ9mPxlMBLlstUcIQ2bVGoqOlI4erUsNzccIv2t0533qCBRPoO15uw IqBchcZm67b8Liv0/e0r4h3RRlWE7Rm09dtsLgdK2hz4xgYXx9eeWpGfsSDzctqzmHWz peCfsZHW0cRdTyse1SLtmq/KfVnIzyvhZVnYX9YdXp0XhzGFh4yb+SV3wf3dMiGjl6yo uKa3q1zlZyXwFx/105Fmx8sbk4DhONZO/FeDLgbixbkM8N2RSyFd4MD7HeJIG7k3NHm9 1bMScIp8d+g8bhKJDFrqCr/uq657zkcAvsdT2/cwRwt004zVyVn5ecJuLmgLmM9UPlSL i9fQ== X-Gm-Message-State: AOAM533t1ZEZPtgDW36c8xNbu3csy7ZJ7DyWfht3ydNeK19dmoxu+ihG 9OPt+vGVkiUIRih88OYNdNvrwGgE2ZAv4TzBASe7OgGcC56b6A== X-Google-Smtp-Source: ABdhPJzxzk/eICXoj47vu5ypG3QenAG3dluh1SP4vGAMvwpZkS/nOAQbnLOkJiVgV6/MSyzUwNDIN3/Bc0fpr5JROS8= X-Received: by 2002:a05:6214:1784:: with SMTP id ct4mr44707543qvb.10.1600637762879; Sun, 20 Sep 2020 14:36:02 -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> In-Reply-To: From: John Cowan Date: Sun, 20 Sep 2020 17:35:52 -0400 Message-ID: To: Steve Nickolas Content-Type: multipart/alternative; boundary="000000000000455b2205afc58527" 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 , Doug McIlroy Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --000000000000455b2205afc58527 Content-Type: text/plain; charset="UTF-8" When 0 is coerced implicitly or explicitly to a pointer type, it becomes a null pointer. That's true even on architectures where all-bits-zero is *not* a null pointer. However, in contexts where there is no expected type, as in a call to execl(), the null at the end of the args list has to be explicitly cast to (char *)0 or some other null pointer. As for the definition of NULL, it is indeed 0 on Linux, but can also be defined as ((void *)0), as on FreeBSD and the Mac, or even as 0L on systems where ints are half-size and pointers and longs are full-size. On Sun, Sep 20, 2020 at 4:59 PM Steve Nickolas wrote: > On Sun, 20 Sep 2020, Doug McIlroy wrote: > > >> (Of course, that assumes NULL is 0, but I don't think I've run into any > >> architecture so braindead as to not have NULL=0.) > > > > It has nothing to do with machine architecture. The C standard > > says 0 coerces to the null pointer. NULL, defined in , > > is part of the library, not the language. I always use 0, > > because NULL is a frill. > > > > Doug > > I was under the impression that there was explicitly no requirement that a > null pointer be 0, and that there was at least one weird system where that > wasn't true - that it just so happened that null points to 0 on certain > CPUs and that 0=NULL *happens* to work on most CPUs but wasn't guaranteed. > (In fact, I read that my habit of using 0 for NULL relied on a faulty > assumption!) > > I mean, I've never actually used a CPU/OS/compiler where it wasn't true, > but... > > -uso. > --000000000000455b2205afc58527 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When 0 is coerced implicitly or explicitly to a pointer ty= pe, it becomes a null pointer.=C2=A0 That's true even on architectures = where all-bits-zero is *not* a null pointer.=C2=A0 However, in contexts whe= re there is no expected type, as in a call to execl(), the null at the end = of the args list has to be explicitly cast to (char *)0 or some other null = pointer.

As for the definition of NULL, it is indeed 0 o= n Linux, but can also be defined as ((void *)0), as on FreeBSD and the Mac,= or even as 0L on systems where ints are half-size and pointers and longs a= re full-size.

On Sun, Sep 20, 2020 at 4:59 PM Steve Nickolas <usotsuki@buric.co>= wrote:
On Sun, = 20 Sep 2020, Doug McIlroy wrote:

>> (Of course, that assumes NULL is 0, but I don't think I've= run into any
>> architecture so braindead as to not have NULL=3D0.)
>
> It has nothing to do with machine architecture. The C standard
> says 0 coerces to the null pointer. NULL, defined in <stddef.h>,=
> is part of the library, not the language. I always use 0,
> because NULL is a frill.
>
> Doug

I was under the impression that there was explicitly no requirement that a =
null pointer be 0, and that there was at least one weird system where that =
wasn't true - that it just so happened that null points to 0 on certain=
CPUs and that 0=3DNULL *happens* to work on most CPUs but wasn't guaran= teed.
(In fact, I read that my habit of using 0 for NULL relied on a faulty
assumption!)

I mean, I've never actually used a CPU/OS/compiler where it wasn't = true,
but...

-uso.
--000000000000455b2205afc58527--