Xref: utzoo comp.lang.c:6401 comp.sys.m68k:667 Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!lll-lcc!lll-winken!uunet!steinmetz!ge-dab!codas!ateng!chip From: chip@ateng.UUCP (Chip Salzenberg) Newsgroups: comp.lang.c,comp.sys.m68k Subject: Re: C machine Message-ID: <155@ateng.UUCP> Date: 19 Jan 88 23:17:03 GMT References: <461@auvax.UUCP> <9961@mimsy.UUCP> <166@teletron.UUCP> <6936@brl-smoke.ARPA> <147@ateng.UUCP> <39aca826.7f32@apollo.uucp> <7092@brl-smoke.ARPA> <708@umbc3.UMD.EDU> <7109@brl-smoke.ARPA> <712@umbc3.UMD.EDU> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Organization: A T Engineering, Tampa, FL Lines: 29 In the beginning, gwyn@brl.arpa (Doug Gwyn) wrote: >First, only pointers into the same object can meaningfully be subtracted. >Second, the result of the subtraction necessarily has implementation- >defined signed integral type; there is a typedef ptrdiff_t in . Then alex@umbc3.UMD.EDU (Alex S. Crain) asks what dpANS says about code like: > funcall (ptr1 - ptr2); /* ptr1 - ptr2 > 64k */ The expression "ptr1 - ptr2" evaluates to an expression of the type ptrdiff_t. If you did your homework, then you defined the parameter to funcall as a ptrdiff_t, so your stack will line up neatly. But Doug did not mention whether ptrdiff_t is a signed or unsigned type. Or is this not specified in dpANS? When will I stop asking rhetorical questions? :-) > I would prefer 32bit (or rather, the largest default integer available >including pointers) ints, because conversion to short int is absolutely >painless (mov.l becomes mov.w) while conversion the other way can be a rather >serious problem. Conversion from 32 bits to 16 bits is painless, but for many architectures, manipulation of 32-bit quantities is awkward and/or slow. Thus X3J11 is avoiding (whenever possible) giving minimum sizes for standard types. Repeat after me: "Not all C programs run on 32-bit architectures." -- Chip Salzenberg UUCP: "{codas,uunet}!ateng!chip" A T Engineering My employer's opinions are a trade secret. "Anything that works is better than anything that doesn't."