Back when we were running v5 at the University of Toronto, we had a
graphics device that we accessed, on our split I&D space 11/45, using 0,
something like this:
struct x {
int reg0, reg1, ...;
};
0->reg1 = 0234;
Several old details of old C made this possible as well: Struct tags were
global, -> worked on any pointer, and ints and pointers were
interchangeable.
-rob
On Tue, Sep 22, 2020 at 6:51 AM John Cowan <cowan(a)ccil.org> wrote:
On Mon, Sep 21, 2020 at 1:55 AM Steve Nickolas <usotsuki(a)buric.co> wrote:
I've never written anything that uses
varargs, so I've never run into
that. But I've actually done quite a bit of work with an environment
where this isn't true: MS-DOS using the large or huge model. In this
environment, sizeof(int)=2, and sizeof(void*) is 4. Of course, it's not
conformant to pass an int variable as an argument where a pointer variable
is expected.
If the compiler was ISO-conformant (which it almost certainly was not),
that would not matter. 0 in int context would be a 2-byte int with all
bits zero, and 0 in pointer context would be a 4-byte null pointer,
probably with all bits zero.
C doesn't require that the address represented by the null pointer
(whether or not it is all-bits-zero) is inaccessible, merely that there is
no C object or function there. A simple shim of the appropriate size (1,
2, 4, 8 bytes depending on the CPU's alignment rules) will suffice.