News for hackers. Stuff that matters.
Re:A critique of "How to C in 2016" by cataphract on Friday January 15, 2016 @06:48AM (#10908658)
Isn't another problem of "ptrdiff_t diff = (uintptr_t)ptrOld - (uintptr_t)ptrNew;" that you're assigning an unsigned value to a signed variable?

If ptrNew is larger than ptrOld this can give a very large value via wrapping around, so large that it will probably be bigger than the max value of ptrdiff_t, making the assignment a form of signed overflow.

Re:A critique of "How to C in 2016" by xcgvgh on Friday January 15, 2016 @06:53AM (#10908681)
The assignment is a conversion from unsigned to signed, if the value cannot be represented by the signed type, the result is implementation defined or an implementation defined signal is triggered.
Re:A critique of "How to C in 2016" by cataphract on Friday January 15, 2016 @09:30AM (#10909478)
Right. Implementation defined, not undefined. Still not great for portable code, which is what the article is all about.
Re:A critique of "How to C in 2016" by xcgvgh on Friday January 15, 2016 @10:12AM (#10909720)
It's also very dangerous.