std :: ptrdiff_t . std :: size_t is unsigned. Listing strlen(p) to ptrdiff_t makes sense if p can have a negative length, which is not possible.
However, this tide can overflow the resulting signed value if p is large enough (for example, on most 32-bit platforms, more than 2,147,483,647 bytes). Thus, this can lead to an error in your pointer arithmetic.
It is best to stick with size_t here.
FrΓ©dΓ©ric hamidi
source share