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 9341 invoked from network); 21 Sep 2020 01:06:29 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 21 Sep 2020 01:06:29 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 1904094483; Mon, 21 Sep 2020 11:06:28 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 55CB3940FD; Mon, 21 Sep 2020 11:05:41 +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="PqUd+LYu"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id E2C25940FD; Mon, 21 Sep 2020 11:05:37 +1000 (AEST) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by minnie.tuhs.org (Postfix) with ESMTPS id B199493F5B for ; Mon, 21 Sep 2020 11:05:36 +1000 (AEST) Received: by mail-qk1-f182.google.com with SMTP id f142so13378571qke.13 for ; Sun, 20 Sep 2020 18:05:36 -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=kHkkFkhq6t1ku661SSIJdPqg61/VShbzNeO87jt/Zjg=; b=PqUd+LYuYHbHbFFipc/dT/0YWwvlZeZZEUfQw6hXSuBJxlWUYXWhk+K4puA16xkC5Y yV8UuteT5Yy7yPc1bq4hw5cAj9ytbv1XmFhuY59DkHsL3GtjuMTVP56Fx/k/WrgTo+0r 2IVwyhc9M1UBlAlPpKx01rqRzz6hg8Mfaf48s= 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=kHkkFkhq6t1ku661SSIJdPqg61/VShbzNeO87jt/Zjg=; b=T5r80qQ7NyTuwNPLX/oXRce8R66i0SC8WKBIsTo1cVo4+o7IYBS5vxKUie/wHcSr0X a33UC9WlzGB4sCdO1O/UOQ9tIub4hY5BUnY3WoHdHjxEVUWo+/fZwf+KNG+3r43psSuZ wz0BKG4fJ9Q+nDb/CJ2tD0I6EAJ8KsRXJbDY83IqWyWhNM4b8o1DHyWgBPsQ6TNJBknr 3z5T6ej+sjXIcTCUpsTDS3DC9KNtdfzxB9l8Xr9wLb8iOleE7l/+crE0U4KKD9S6H6FL x/0Chl9S0pvJsRz5nQ4tkDCTXviQHjSIPplAQfzj9i3BrGKa3Ff2H1dU2/Rwb3+t6tHe LGMQ== X-Gm-Message-State: AOAM533AFBNmuAm9KSm7vpbjSp8urv7OUi/aIQXFs2yXJuloe0uys5b9 7yzU6yKgxWGvKU6Rzv7xJVkgKtULVnU/4zkvstZz5g== X-Google-Smtp-Source: ABdhPJwzogvIwlVa+RLhAWhMKO9H5SloDh+MHvtmumtFMssqAHIat7FMjkoA1sdOZit68pHVxmLJrSipfEpUzUQRStU= X-Received: by 2002:a37:7ac1:: with SMTP id v184mr2483878qkc.146.1600650335445; Sun, 20 Sep 2020 18:05:35 -0700 (PDT) MIME-Version: 1.0 References: <20200920230057.C5D1A4422E@lignose.oclsc.org> In-Reply-To: From: Clem Cole Date: Sun, 20 Sep 2020 21:05:23 -0400 Message-ID: To: Warner Losh Content-Type: multipart/alternative; boundary="000000000000a7f79705afc872b4" 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" --000000000000a7f79705afc872b4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yep. They all suck. As Dennis said, =E2=80=9CC is quirky=E2=80=9D and pa= rt of the issue is HW is even more so. Clem On Sun, Sep 20, 2020 at 8:10 PM Warner Losh wrote: > To two places: stddef.h and stdlib.h :(. > > It's interesting to see the different bugs 0, 0L, (char *)0 and (void *)0 > expose or hide as definitions of NULL. > > 0 is fine if sizeof(int) =3D=3D sizeof(void *). Otherwise varadic functio= n > calls break. 0L is the same, but for long. The pointer definitions run in= to > trouble in other contexts since NULL is often incorrectly used as a > terminating byte in a string instead of '\0'. (void *) has issues with > const pointers, some of which are relevant if you use it in the wrong > context. > > There were quite spirited debates back in the day for which one was best. > They all suck. C++ invented a null pointer symbol because it's type rules > were enough different than C to make a universal NULL #define impossible. > Is that better or worse? Don't know. It's different. > > Glad to see the null-pointer need not have all zero bits being different > than a 0 constant shall be the null-pointer in sufficient detail. > > Warner > > On Sun, Sep 20, 2020, 5:54 PM Clem Cole wrote: > >> Norman NULL has to be defined and I said that/showed it. The standard >> says where. I was not trying to compile NULL without a definition which= I >> agree it not legal. If that is what Doug was implying I missed understo= od >> him but I note NULL was introduced in Typesetter C /V7 where those compi= ler >> s set it to 0 in studio but the ANSI/ISO moved it. >> >> On Sun, Sep 20, 2020 at 7:03 PM Norman Wilson wrote: >> >>> Doug McIlroy: >>> >>> >>> >>> To put it more strongly. this is not a legal C source file. >>> >>> char *s =3D NULL; >>> >>> But this is. >>> >>> char *s =3D 0; >>> >>> >>> >>> Clem Cole: >>> >>> >>> >>> 67)The macro NULL is defined in (and other headers) as a >>> null >>> >>> pointer constant; see 7.19. >>> >>> >>> >>> =3D=3D=3D=3D >>> >>> >>> >>> $ cat null.c >>> >>> char *s =3D NULL; >>> >>> $ cat zero.c >>> >>> char *s =3D 0; >>> >>> $ >>> >>> >>> >>> zero.c is a legal C program. null.c is not. Create >>> >>> files exactly as shown and compile them if you don't >>> >>> believe me. >>> >>> >>> >>> Prepend `#include ' (or or ) >>> >>> to null.c and it becomes legal, but I think that's Doug's >>> >>> point: you need an include file. >>> >>> >>> >>> Personally I prefer to use NULL instead of 0 when spelling >>> >>> out a null pointer, because I think it's clearer: >>> >>> if ((buf =3D malloc(SIZE)) =3D=3D NULL) >>> >>> error("dammit andrew"); >>> >>> though I am willing to omit it when there's no confusion >>> >>> about =3D vs =3D=3D: >>> >>> if (*p) >>> >>> dammit(*p, "andrew"); >>> >>> >>> >>> But that's just a question of style, and Doug's is fine too. >>> >>> >>> >>> The language does not require the compiler to pre-define >>> >>> NULL or to recognize it as a keyword; you have to include >>> >>> an appropriate standard header file. >>> >>> >>> >>> Norman Wilson >>> >>> Toronto ON (not 0N nor NULLN) >>> >>> -- >> Sent from a handheld expect more typos than usual >> >> >> > > -- Sent from a handheld expect more typos than usual --000000000000a7f79705afc872b4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yep. =C2=A0 They all suck.=C2=A0 As Dennis said, =E2=80= =9CC is quirky=E2=80=9D and part of the issue is HW is even more so.=C2=A0 = Clem

On Sun, Sep 20, 2020 at 8:10 PM Warner Losh <imp@bsdimp.com> wrote:
To two places: stddef.h and stdlib.h :(.<= /div>

It's interesting to = see the different bugs 0, 0L, (char *)0 and (void *)0 expose or hide as def= initions of NULL.

0 is f= ine if sizeof(int) =3D=3D sizeof(void *). Otherwise varadic function calls = break. 0L is the same, but for long. The pointer definitions run into troub= le in other contexts since NULL is often incorrectly used as a terminating = byte in a string instead of '\0'. (void *) has issues with const po= inters, some of which are relevant if you use it in the wrong context.

There were quite spirited de= bates back in the day for which one was best. They all suck. C++ invented a= null pointer symbol because it's type rules were enough different than= C to make a universal NULL #define impossible. Is that better or worse? Do= n't know. It's different.=C2=A0

Glad to see the null-pointer need not have all zero bits be= ing different than a 0 constant shall be the null-pointer in sufficient det= ail.

Warner

On Sun, Sep 20, 2020, 5:54 PM Clem Cole <clemc@ccc.com> wrote:
Norman NULL has to = be defined and I said that/showed it. =C2=A0 The standard says where.=C2=A0= I was not trying to compile NULL without a definition which I agree it not= legal.=C2=A0 If that is what Doug was implying I missed understood him but= I note NULL was introduced in Typesetter C /V7 where those compiler s set = it to 0 in studio but the ANSI/ISO moved it.=C2=A0

On Sun, Sep 20, 2020= at 7:03 PM Norman Wilson <norman@oclsc.org> wrote:
Doug McIlroy:



=C2=A0 To put it more= strongly. this is not a legal C source file.

=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 char *s =3D NULL;

=C2=A0 But this is.

=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 char *s =3D 0;



Clem Cole:


=C2=A0 =C2=A067)The macro NULL is defined in <stddef.h> (and= other headers) as a null

=C2=A0 =C2=A0pointer constant; see 7.19.


=3D=3D=3D=3D



$ cat null.c

char *s =3D N= ULL;

$ cat zero.c

char *s =3D 0;

$



zero= .c is a legal C program.=C2=A0 null.c is not.=C2=A0 Create

files exa= ctly as shown and compile them if you don't

believe me.

<= br>
Prepend `#include <stddef.h>' (or <stdlib.h> or <= stdio.h>)

to null.c and it becomes legal, but I think that's = Doug's

point: you need an include file.



Personall= y I prefer to use NULL instead of 0 when spelling

out a null pointer= , because I think it's clearer:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (= (buf =3D malloc(SIZE)) =3D=3D NULL)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 error("dammit andrew");

though I = am willing to omit it when there's no confusion

about =3D vs =3D= =3D:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (*p)

=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 dammit(*p, "andrew");

=

But that's just a question of style, and Doug's is fine too= .



The language does not require the compiler to pre-define
NULL or to recognize it as a keyword; you have to include

an a= ppropriate standard header file.



Norman Wilson

Toront= o ON (not 0N nor NULLN)

--
Sent from a handheld expect more ty= pos than usual




--
Sent from a handheld expect more typos than usua= l
--000000000000a7f79705afc872b4--