Path: utzoo!attcan!uunet!portal!cup.portal.com!Don_A_Corbitt From: Don_A_Corbitt@cup.portal.com Newsgroups: comp.lang.c Subject: Re: use of NULL Message-ID: <14952@cup.portal.com> Date: 22 Feb 89 18:09:17 GMT References: <1167@unisec.usi.com. <5312@turnkey.TCC.COM. <9582@smoke.BRL.MIL. <399@twwells.uucp: <973@optilink.UUCP> Organization: The Portal System (TM) Lines: 22 Clayton, Counter example time for MSC and NULL. (We already know of many counter examples for other machines, such as Pyramid...) Compact model (data pointer 32 bit, function pointer 16 bit). Function that has a function pointer argument called if error occurs (or calls exit() if no error handler passed in...) void DoSomething(int p1, int p2, void (*errhand)(int)); (oops - make this medium model - 32 bit code pointer, 16 bit data) Call DoSomething with no function prototype: (and no error handler) DoSomething(100, 200, NULL); NULL is defined as 0 (16 bits). DoSomething detects an error, checks the errhand parameter, it is not 0 (32 bits), so it calls the function. If you cast NULL to a function pointer, it will pass a 32 bit pointer, and all is well. Don_A_Corbitt@cup.portal.com