by stromgo · 10y ago · 0 comments
In practice it works only if sizeof(ptrdiff_t) == sizeof(uintptr_t) AND the system uses two's complement for signed integers. Neither property is guaranteed by the standard.
I think the correct way to find the byte offset is this:
ptrdiff_t diff = (char*)ptrOld - (char*)ptrNew;~1 beat~
Yikes!
~leaves self-shaped dust cloud behind as hurriedly runs toward higher [level] ground~