Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: pointer debate raging on... (short) Message-ID: <1777@dg_rtp.UUCP> Date: Tue, 28-Apr-87 14:57:06 EDT Article-I.D.: dg_rtp.1777 Posted: Tue Apr 28 14:57:06 1987 Date-Received: Thu, 30-Apr-87 02:18:13 EDT References: <149@sds.UUCP> Lines: 35 > dave@sds.UUCP (dave schmidt x194) > Applaud, applaud, applaud. John has correctly pointed out that > sizeof(pointer) == sizeof(int) is not the universal constant that > many people believe it to be. It is for this exact reason that > NULL should ***NOT*** be defined as 0. Boo, hissss, razzzz. Dave seems to incorrectly think that sizeof(pointer) == sizeof(void *). Now, granted, he comes breifly to his senses and says... > A minor problem still exists even with defining NULL as (void *)0; > NULL cannot be passed to a routine as function pointer without > a cast since sizeof(void (*)()) may not be the same as sizeof(void *). > That, however, is something that shouldn't cause too much trouble. ... which is correct, as far as it goes. But it doesn't go far enough. The problem isn't minor, since there exist machines where (void *) is larger than many other pointer types. Further, machines where there *IS* no single type which has the correct length for all likely uses of null pointers are *COMMON*. (You've heard of the 80x86 series, right?) Thus, giving the constant NULL a specific pointer type, *ANY* specific pointer type, does *NOT* solve the problem it is purported to solve, that is, passing NULL as an actual argument to a formal argument of pointer type. NULL must *STILL* *ALWAYS* be cast to the appropriate type in such cases, even when the constant is (incorrectly) defined as (void *)0. -- It is easy to find fault, if one has that disposition. There was once a man who, not being able to find any other fault with his coal, complained that there were too many prehistoric toads in it. --- Pudd'nhead Wilson's Calendar (Mark Twain) -- Wayne Throop !mcnc!rti-sel!dg_rtp!throopw