From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,12b6bb94ebde41c,start X-Google-Attributes: gidfee84,public From: tsaylor@ecst.csuchico.edu (Todd M. Saylor) Subject: Dereferencing NULL pointer? Date: 1997/05/21 Message-ID: <5lteva$q0e@charnel.ecst.csuchico.edu>#1/1 X-Deja-AN: 242697926 Organization: California State University, Chico Newsgroups: comp.unix.osf.osf1 I am currently in the process of porting an application to Digital UNIX 4.0b (it's never been run on an alpha before). The app runs fine on HP/UX, AIX, DG/UX (motorola and Intel), AT&T/NCR. One problem has come up on previous ports, that is the ability to dereference a NULL pointer. For the OS's that hate this, we've always found a linker option to allow it (basically return a null character) - for example on DG it would be '-z lowzeros'. The following code demonstrates what I mean: main() { char *x; x = (char *)NULL; printf("Null string = '%s'\n", x); /* This works fine */ printf("Null Char = '%c'\n", *x); /* This get a seg. violation */ } Now this may be bad form, but I was wondering if anyone knows of a switch/option to allow it? TIA [Posted for Aaron Johnson / aaron@bi-tech.com] --