Referencing through a null pointer

Mike Percy grimlok at hubcap.UUCP
Tue Apr 26 04:40:23 AEST 1988


>From article <4729 at cup.portal.com>, by Paul_L_Schauble at cup.portal.com:
> Could someone please tell me which machine it was that started the
> unfortunate convention that referencing through the null pointer returns a
> zero with no error? I was under the impression it was BSD Unix, but I'm not
> sure.
> 
>     Thanks,
>        Paul

Well, I don't know bout this, but I do know that at least some compilers
try to give some sort of indication that you have reda or written
through a null pointer. For instance, when I use TurboC and do this:

  printf("%s",some_char_star_pointer);

I get
  
  (null)

which is real nice.
Only good for strings though, but it is also useful, but not quite so
obviously, that on termination, it seems that TC also checks the values
at &(NULL) and if what is there is not what should be there you get the
message

 (null pointer reference)

(that is, if your program manages to terminate "properly")

Note that I have not gotten elbow deep verifying exactly how TC
implements this, but it seems simple enough to me.


volatile --- yeaah!
noalias --- ppppppphbbblllaaatthhh



More information about the Comp.lang.c mailing list