Referencing NULL pointers
T.S. Hadley
hadley at ics.uci.edu
Mon Jul 10 15:38:42 AEST 1989
Greetings.
By NULL pointer referencing I mean: consider the C frags:
..
char *s = (char *) 0, t[10];
strcpy(t, s);
...
/* or */
...
TYPE *t = (TYPE *) 0; /* typedef struct { ... } TYPE; */
if(t->field == 0)
...
On my machine (sun) these statements causes segmentation violations
during runtime.
Apparantly, on other machines this is perfectly valid, since I see
quite a lot of this in code created on certain non-sun machines.
What can I do about it? Is there a flag on some C compiler to handle
these situations? (gcc -fallow-null-pointer-referencing-idiocy :-)
Apologies if this subject is a dead horse.
Grateful Thanks.
--
Tedd Hadley (hadley at ics.uci.edu)
More information about the Comp.unix.wizards
mailing list