On Dec 27, 2011, at 15:08, McKown, John wrote:
>
> I seen this type of thing in a lot of C code as well. But it depends on the 
> programmer remembering to check the next pointer for NULL. So what occurred 
> to me was: "Why doesn't the hardware do this?".
>
> Good idea? Or stupid?
>
You're paddling against the current here.  So many UNIX systems store
a byte (word, longword) of zero at address zero that many programmers
irresponsibly code:

    char *S = 0;

when they should code:

    char *S = "";

(Well, the first form saves one keystroke and one byte of storage in
each of the source text and the execution image), then process S as
a possibly empty null terminated string.

Then they report it to IBM as a problem when the code fails on MVS,
which is nearly guaranteed not to have a 0 at location 0.  "Well it
works on system X!"  IBM relented about OS/390 and modified pointer
checking code to replace any reference to 0 with with a reference
to an address containing 0.

The immediate adverse consequence was that library routines that
formerly gave lucid error messages reporting invalid pointer
arguments subsequently misbehaved in unpredictable fashions.

Alas,
gil

Reply via email to