The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] reviving a bit of WWB
@ 2020-09-19  1:51 Doug McIlroy
  2020-09-20 18:42 ` arnold
  0 siblings, 1 reply; 60+ messages in thread
From: Doug McIlroy @ 2020-09-19  1:51 UTC (permalink / raw)
  To: tuhs

I would like to revive Lorinda Cherry's "parts".
Implicit in "revival" is dispelling the hundreds
of warnings from  gcc -Wpedantic -Wall -Wextra.
Has anybody done this already?

Doug

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [TUHS] reviving a bit of WWB
@ 2020-09-20 22:51 Norman Wilson
  0 siblings, 0 replies; 60+ messages in thread
From: Norman Wilson @ 2020-09-20 22:51 UTC (permalink / raw)
  To: tuhs

Brantley Coile:

  The fact that a pointer of zero generates a hardware trap is not
  defined in the language, whereas a 0 is is defined to be a null pointer.

=====

The language doesn't require that dereferencing a null pointer
cause a trap, either.  There's no way to guarantee that behaviour
in all environments unless every pointer dereference must include
instructions to check for the null-pointer value, because C can
run in environments in which any pointer value might be a valid
address.

On modern machines it's conventional for the null-pointer value
in C, what you get when you assign 0 to a pointer, to be all-zeroes;
and for operating systems to arrange that that address is unmapped.
But that wasn't always so (on the PDP-7 there was no memory map;
on the PDP-11 once memory-mapping was added, address space was
too dear to throw away an eighth of it just to block null-pointer
dereferencing), and it may still not be (consider a C program
on an embedded system running without a memory map).

It's good that modern systems usually whap you in the head if you
deference a null pointer, but it's not required, and those who
rely on it are as foolish as those who used to rely on the
accident that the byte at address 0 on early VAX UNIX was a zero.

Norman Wilson
p&p6 and f(

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [TUHS] reviving a bit of WWB
@ 2020-09-20 23:00 Norman Wilson
  2020-09-20 23:53 ` Clem Cole
  0 siblings, 1 reply; 60+ messages in thread
From: Norman Wilson @ 2020-09-20 23:00 UTC (permalink / raw)
  To: tuhs

Doug McIlroy:

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

Clem Cole:

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

====

$ cat null.c
char *s = NULL;
$ cat zero.c
char *s = 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 <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.

Personally I prefer to use NULL instead of 0 when spelling
out a null pointer, because I think it's clearer:
	if ((buf = malloc(SIZE)) == NULL)
		error("dammit andrew");
though I am willing to omit it when there's no confusion
about = vs ==:
	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)

^ permalink raw reply	[flat|nested] 60+ messages in thread
* Re: [TUHS] reviving a bit of WWB
@ 2020-09-25 14:19 Doug McIlroy
  2020-09-28 17:35 ` Angelo Papenhoff
  0 siblings, 1 reply; 60+ messages in thread
From: Doug McIlroy @ 2020-09-25 14:19 UTC (permalink / raw)
  To: tuhs

> Turing save us from 1-complement machines!

Users of Whirlwind II were warned about the quirks of -0.
We were not warned, though, about integer divide with remainder 0.
The result of dividing 6 by 3, for example, was binary 1.111111... -
a valid answer when carried to infinity. Unfortunately, the
"fractional" part was dropped.

Most people used Whirlwind for floating-point computation, and
blithely dismissed printed answers like 1.999999 as "roundoff
errors".

Doug

^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2021-02-03 23:47 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19  1:51 [TUHS] reviving a bit of WWB 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
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

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).