Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!trwrb!trwrba!cepu!ucla-cs!alex From: alex@ucla-cs.UUCP Newsgroups: net.unix-wizards Subject: Re: Xenix286 Wonders, Bugs, and Patches... Message-ID: <5369@ucla-cs.ARPA> Date: Sat, 11-May-85 23:49:59 EDT Article-I.D.: ucla-cs.5369 Posted: Sat May 11 23:49:59 1985 Date-Received: Thu, 16-May-85 02:36:10 EDT References: <10550@brl-tgr.ARPA> Reply-To: alex@ucla-cs.UUCP (Alex Quilici) Followup-To: net.lang.c Distribution: net Organization: UCLA Computer Science Department Lines: 32 [Yes, Virginia, people do post without thinking!] In article <10550@brl-tgr.ARPA> BARNES@TL-20A.ARPA writes: >In article <2158@sun.uucp> guy@sun.uucp (Guy Harris) writes: >>> exec() doesn't always work with the large model due to NULL being >>> placed at the end of the arg list instead of (char *)NULL. This is a >>> programmer problem more than a bug... > >NULL is usually declared in stdio.h as: > #define NULL 0 >Kernighan & Ritchie on page 98 state explicitly that, "In general, integers >cannot meaningfully be assigned to pointers; zero is a special case." On the >previous page they state, "C guarantees that no pointer that validly points at >data will contain zero, ..." > >Thus, the code is not buggy in the least; with or without casting... Aaaaarrrrrggggghhhhhhhh! How about net.lang.c.bozo? When NULL is passed as a parameter the compiler doesn't necessarily know that NULL is supposed to be a pointer and should possibly be widened or otherwise modified. After all NULL is simply 0; the context surrounding its use determines whether it is a pointer. Since functions can be defined in different files and compiled separately, the formal parameter declarations for the called function aren't guaranteed to be available when the function is compiled, and one must explicitly cast the NULL parameter to a pointer if one wants to write correct code. The bug, as Guy pointed out, is in the programmer rather than the compiler. And the bug seems to be amazingly difficult to get rid of. Alex Quilici alex@ucla-cs {ucbvax, ihnp4}!ucla-cs!alex