On 5 January 2016 at 19:01, Devon H. O'Dell <devon.odell@gmail.com> wrote:
so given any of the examples in this thread, if you typedef'ed
ptrdiff_t to long, then the compiler technically isn't actually doing
anything wrong. whether it is doing something useful is a different
question.

Well, although I knew that was true, I didn't want to push the point because
in practice, people have a right to expect certain reasonable behaviour,
and it's quite reasonable to expect that p+(q-p) yields q if they both point
into the same array that the system agreed to allocate somehow.
It make sense to use 64 bits for the difference, and indeed the code
block that adds the current cast has an if(1 && ...) suggesting an if(0 && ...
to be inserted instead. It would have been better if I'd simply named it by enum and
added a comment to explain some of this.

There are some effects on library interfaces that I didn't mention earlier, but
since 64-bit operation should now be as common as not (allowing for 32-bit ARM),
it makes sense to update everything to cope with it properly.