>>>>> "Vincent" == Vincent Lefevre <[EMAIL PROTECTED]> writes:
Vincent> 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?
Vincent> 6.5.6 Additive operators [...] [#9] When two pointers are
Vincent> subtracted, both shall point to elements of the same array
Vincent> object, or one past the last element of the array object;
Vincent> the result is the difference of the subscripts of the two
Vincent> array elements. The size of the result is
Vincent> implementation-defined, and its type (a signed integer type)
Vincent> is ptrdiff_t defined in the <stddef.h> header. If the
Vincent> result is not representable in an object of that type, the
Vincent> behavior is undefined. In other words, if the expressions P
Vincent> and Q point to, respectively, the i-th and j- th elements of
Vincent> an array object, the expression (P)-(Q) has the value i-j
Vincent> provided the value fits in an object of type ptrdiff_t.
Vincent> [...]
Vincent> See the sentence "If the result..." and the last few words
Vincent> of the next sentence.
Bizarre. Is there a real world example where this is done? I can't
imagine any place where this exception is justified.
paul