tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NULL pointer arithmetic issues

On 2020-02-24 21:24, Kamil Rytarowski wrote:
On 24.02.2020 21:18, Mouse wrote:
If we use 0x0, it can be a valid pointer.

If we use NULL, it's not expected to work and will eventually
generate a syntax erro.

Then someone has severely broken compatability with older versions of
C.  0x0 and (when one of the suitable #includes has been done) NULL
have both historically been perfectly good null pointer constants.

Also...syntax error?  Really?  _Syntax_ error??  I'd really like to see
what they've done to the grammar to lead to that; I'm having trouble
imagining how that would be done.

The process of evaluation of the NULL semantics is not a recent thing.

Not so long time, still in the NetBSD times, it was a general practice
to allow dereferencing the NULL pointer and expect zeroed bytes over there.

We still maintain compatibility with this behavior (originated as a hack
in PDP11) in older NetBSD releases (NetBSD-0.9 Franz Lisp binaries
depend on this).

Really? I thought we usually do not have anything mapped at address 0 to explicitly catch any dereferencing of NULL pointers.

But yes, on the PDP11 this was/is not the case. Memory space is too precious to allow some of it to be wasted for this... (Even if there are a comment about it in 2.11BSD, bemoaning this fact...)


Johnny Billquist                  || "I'm on a bus
                                  ||  on a psychedelic trip
email:             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol

Home | Main Index | Thread Index | Old Index