Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!oddjob!hao!noao!mcdsun!fnf From: fnf@mcdsun.UUCP (Fred Fish) Newsgroups: comp.sys.amiga Subject: Re: Manx C Message-ID: <351@mcdsun.UUCP> Date: Thu, 6-Aug-87 12:01:21 EDT Article-I.D.: mcdsun.351 Posted: Thu Aug 6 12:01:21 1987 Date-Received: Sat, 8-Aug-87 12:09:56 EDT References: <4540@jade.BERKELEY.EDU> <1836@vax135.UUCP> <4595@jade.BERKELEY.EDU> <3199@zen.berkeley.edu> Reply-To: fnf@mcdsun.UUCP (Fred Fish) Distribution: comp Organization: Motorola Microcomputer Division Lines: 38 Keywords: look at the assembly. In article <3199@zen.berkeley.edu> waterman@cory.Berkeley.EDU.UUCP (T.S. Alan Waterman) writes: >Mike, the deal with this problem is this: > > if (ptr == 0) compares the pointer with an INT, which is gonna be 16 bits. > That is, is hacks ptr in half and compares the bottom half with 0 (16 bits). No, Mike was right. Bear in mind that I haven't actually tried the example given to see what the generated code is, but if it is as you described above then it is broken. From draft proposed Ansi C standard, 3.2.2.3: "An integral constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant. If a null pointer constant is assigned to or compared for equality to a pointer, the constant is converted to a pointer of that type. ..." In other words, the 16 bit int is widened to 32 bits, not the other way around. Now granted, Manx C is hardly "Ansi C", but the above rule is not something new with Ansi C. > >In short, the error message is correct. You are being rightly warned the the >compiler is about to do exactly what you told it to, and not really what >you wanted to do. Oh, BTW, defining anything as a ((void *) x) makes a long- >word (32 bit) value, whether x is long or not. If it behaves as you believe, the compiler is rightly warning that it it doing whatever it feels like, not what you told it to, or what it should be doing. :-) -Fred -- = Drug tests; just say *NO*! = Fred Fish Motorola Computer Division, 3013 S 52nd St, Tempe, Az 85282 USA = seismo!noao!mcdsun!fnf (602) 438-3614