On 2005-07-17 12:55:38 -0400, Paul Koning wrote: > Are you sayinvg that a-b is not always "guaranteed to work" when a > and b point to elements of the same array? That sounds wrong; can > you given an example or standards text that supports this?
6.5.6 Additive operators [...] [#9] When two pointers are subtracted, both shall point to elements of the same array object, or one past the last element of the array object; the result is the difference of the subscripts of the two array elements. The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header. If the result is not representable in an object of that type, the behavior is undefined. In other words, if the expressions P and Q point to, respectively, the i-th and j- th elements of an array object, the expression (P)-(Q) has the value i-j provided the value fits in an object of type ptrdiff_t. [...] See the sentence "If the result..." and the last few words of the next sentence. -- Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/> Work: CR INRIA - computer arithmetic / SPACES project at LORIA