[TUHS] speaking of early C compilers

Ronald Natalie ron at ronnatalie.com
Tue Oct 28 06:35:57 AEST 2014


The original UNIX system calls returned error by setting the CARRY ("C") bit on the PSW.
It was the little wrapper to make them C callable that mapped that to -1.   Yes, there was much cleanup going to
Version 7 to get rid of using -1 with pointers in lieu of the null pointer.    The original argv list was terminated with a -1
as well.

Not that loading from *(int*) 0 was ever a good idea.   On the PDP-11, you got garbage...specifically the first few instructions of the program,
the first of which was "setd" and if you did "printf("%s\n", 0), you got something like "p&P6" printed out.

Some idiot decided in the split I/D mode (and later on the VAX) to put a ZERO at location zero.   This led to a lot more sloppy coding.
We moved to the Gould SEL machines and like your machine, the default was to get a trap on *(int*)0 as there was nothing mapped there.
We subsequently added a flag to the a.out format that changed this behavior (called "braindamaged vax compatibility mode") to map a zero
at zero for the few programs we only had in binary form and we couldn't fix their errant behavior.

> 
> The cast syntax, arguably one of the ickiest parts of C syntax, was
> invented in desperation -- we needed the feature, and there was no good
> syntax proposal.  I blush to admit that the one Dennis chose is one that I
> suggested, largely because (unlike some of the others) it was easy to
> implement in Yacc.

Yep, the problem was that the book said that a cast was to perform the same operation as assigning a value to an
invented temporary of the cast type.   This of course, didn't fully explain it in the case of some cast behavior.   C++
had to devolve the C cast into FIVE different kinds of cast to make it sane.





More information about the TUHS mailing list