Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!topaz!husc6!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: printf() code size using Astartup.obj and AMIGA.LIB only Message-ID: <2317@umcp-cs.UUCP> Date: Wed, 9-Jul-86 13:38:56 EDT Article-I.D.: umcp-cs.2317 Posted: Wed Jul 9 13:38:56 1986 Date-Received: Fri, 11-Jul-86 06:07:03 EDT References: <8606270438.AA07486@pavepaws> <426@oscvax.UUCP> <84@unisoft.UUCP> <566@3comvax.UUCP> <1385@well.UUCP> <951@jade.BERKELEY.EDU> Reply-To: chris@maryland.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 57 In article <951@jade.BERKELEY.EDU> mwm@eris.UUCP () writes: >Also, if foo is a pointer type, the test (!foo) is wrong. NULL doesn't >have to be zero. (Old ground again. . . .) NULL *does* have to be zero, and the test is not wrong. Any null pointer must compare equal to the integer constant zero. Any null pointer may contain a non-zero bit pattern. Do you understand the difference? (If so, stop reading now.) The difference is that the integer constant zero is only a zero before compilation. There is no conceptual reason that it cannot mutate in the process of code generation. For example, consider a Vax compiler that uses the bit pattern 0xc0000000 as the null pointer (0xc0000000 is an illegal address on a Vax). The compiler might turn this: register char *p = 0; ... if (!p) ... into this: movl $0xc0000000,r11 # p = 0 ... cmpl $0xc0000000,r11 # if (!p) jneq L70 # branch if p == 0 ... The same compiler would also generate different code for long t, time(); t = time(0); and long t, time(); t = time((long *)0); The former might generate the following: pushl $0 # 0 calls $1,_time movl r0,-4(fp) and the latter: pushl $0xc0000000 # (long *)0 calls $1,_time movl r0,-4(fp) Now do you see the difference? -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu