What requires this calloc call to fail? C11? POSIX? For all sizes > PTRDIFF_MAX? Or > SIZE_MAX?
-
-
Multiple things. The most important is the compiler's inability to handle objects > PTRDIFF_MAX in a consistent manner.
2 replies 0 retweets 0 likes -
Replying to @RichFelker @solardiz
I consider this a bug in compilers. Which would be nice to fix. This is not a requirement of some standard.
2 replies 0 retweets 0 likes -
Supporting objects >PTRDIFF_MAX rather than ensuring they don't exist is a QoI bug even if not a conformance issue.
1 reply 0 retweets 0 likes -
The - operator is not safe to use on pointers unless the implementation precludes objects > PTRDIFF_MAX.
2 replies 0 retweets 0 likes -
Replying to @RichFelker @solardiz
The - operator is only not safe in C for arrays of chars larger than PTRDIFF_MAX.
2 replies 0 retweets 0 likes -
But code accepting 2 ptrs into same array can't assume or even test that diff won't overflow; in practice - is unusable.
1 reply 0 retweets 1 like -
Replying to @RichFelker @solardiz
Oh 1) Only for char array. 2) Can be checked via (uintptr_t).
1 reply 0 retweets 0 likes -
3) Only a problem for generic libraries, self contained app can be sure not to create so large char arrays.
1 reply 0 retweets 0 likes -
4) - can be defined so that it gives right result after a cast to uintptr_t (heh, that's your idea:-)
2 replies 0 retweets 0 likes
But it's not portable. uintptr_t need not exist, and correspondence of uintptr_t arith to ptr arith is intent, not req.
-
-
Replying to @RichFelker @solardiz
Well, I can live with it defined only on platforms with uintptr_t:-)
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.