Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!decwrl!pyramid!prls!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP Newsgroups: comp.lang.c Subject: Re: Pointer Comparison and Portability Message-ID: <2000@mmintl.UUCP> Date: Mon, 23-Feb-87 15:09:06 EST Article-I.D.: mmintl.2000 Posted: Mon Feb 23 15:09:06 1987 Date-Received: Sat, 28-Feb-87 00:25:49 EST References: <814@cullvax.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT Lines: 20 In article <814@cullvax.UUCP> drw@cullvax.UUCP writes: >john@viper.UUCP (John Stanley) writes: >> In the example he gave: >> char p[16], q[16]; >> (Details of 8086 memory addressing omitted.) >> The byte of memory addressed by q[0] and p[17] would >> be the exact same byte, but the two pointers 0002:0000 and 0001:0010 would >> be different. > >Yes, but comparing &p[17] and &q[0] is comparing two addresses derived >from different allocations, and as the standard says, that is >implementation defined (i.e., may not work). Note also that &p[17] is >a correct *pointer*, but attempting to fetch or store anything through >it is not. &p[18] is not a correct pointer. Actually, of course, it is p[16] which is equal to q[0], and &p[17] which is not a correct pointer. Isn't zero-based array indexing wonderful? (:-) Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108