Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!orion.cf.uci.edu!uci-ics!hadley From: hadley@ics.uci.edu (T.S. Hadley) Newsgroups: comp.unix.wizards Subject: Referencing NULL pointers Summary: How to cope? Message-ID: <19367@paris.ics.uci.edu> Date: 10 Jul 89 05:38:42 GMT Sender: news@paris.ics.uci.edu Reply-To: T.S. Hadley Followup-To: comp.unix.wizards Organization: University of California, Irvine - Dept of ICS Lines: 31 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@ics.uci.edu)