Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: C machine Message-ID: <7199@brl-smoke.ARPA> Date: 29 Jan 88 20:01:57 GMT References: <461@auvax.UUCP> <28700025@ccvaxa> <7159@brl-smoke.ARPA> <8728@ism780c.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 15 In article <8728@ism780c.UUCP> marv@ism780.UUCP (Marvin Rubenstein) writes: -The problem with a header file defining a type ptrdiff_t is that the the -defined type must be one of the types in the base C language. If an -implementation defines ptrdiff_t such that sizeof(ptrdiff_t) == sizeof(void*) -then p1-p2 may overflow. "As with any other arithmetic overflow, if the result does not fit in the space provided, the behavior is undefined." It is up to the implementation to choose a reasonable size for ptrdiff_t. -BTW, the definition of pointer difference in K&R is "if p and q point to -members of the same array , p-q is the number of elements between p and q." -One way to interpret this is the following: Yes, that's been fixed in the proposed ANSI C standard.