[Oren Tirosh] > The obvious type to index byte arrays would be ptrdiff_t. > > If (char*)-(char*)==ptrdiff_t then (char*)+ptrdiff_t==(char*) Alas, the standard only says that ptrdiff_t *is* the type of the result of pointer subtraction, not that it *suffices* for that purpose; it explicitly warns that the true result of subtracting two pointers may not be respresentable in that type (in which case the behavior is undefined). In a similar way, C says the result of adding int to int *is* int, but doesn't guarantee the result type (int) is sufficent to represent the true result (and, indeed, in the int case it often isn't). It may be safer to stick with size_t, since size_t isn't as obscure (lightly used and/or misunderstood) as ptrdiff_t.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4