*p++ = *p results?

KW Heuer kwh at bentley.UUCP
Tue Apr 1 07:19:40 AEST 1986


In article <2412 at utcsri.UUCP> utcsri!greg (Gregory Smith) writes:
>[Some] operators have a defined order of execution:
>	if( p != NULL   &&   *p == What_I_am_looking_for )....
>Evaluating *p will crash the program if p==NULL, but since the && operator
>behaves the way it does, this will never happen.

Actually, on many machines dereferencing NULL doesn't crash the program,
it just returns an uninteresting result -- usually causing a program
crash much later, after which it's difficult to track down the bug.

On the 3b2, neither text or data space is anywhere near address zero,
page zero has no interesting contents, yet it is readable.  Apparently
this is so that programs that dereference NULL can be ported!  (I wish
they'd at least make it a loader option, so it could be turned off...)

Karl W. Z. Heuer (ihnp4!bentley!kwh), The Walking Lint



More information about the Comp.lang.c mailing list