Mail Archives: djgpp/1997/02/14/15:48:44
Amit Barak (abarak AT iil DOT intel DOT com) wrote:
: it seems that calling 'strcmp(..)' with one of its arguments equals
: a null pointer causes run-time error (Page fault)
:
: is this normal behavior (compared to other compilers) ?
:
It does vary with compiler and OS/CPU. In ANSI C, it is definitely a
no-no (AKA implementation-dependent behavior :)
Deferencing the NULL pointer is a bad idea. You can assign it and compare
against it for equality. That's about it.
Did you mean to compare against the null string ("")? Even if you don't
get a segment fault, you will get unportable and unpredictable results.
In real mode, large model, low memory is the interrupt vectors and can
change from one run to the next. In small model, some compilers put the
copyright notice there (easy to identify when you print it). Others put a
string like <null pointer> there. Several compilers mak ethe first page
in virtula memory inaccessible to catch attempts to dereference NULL (and
small integers).
Jeff
- Raw text -