... is it safe to do nullptr pointer arithmetic?
No, arithmetic on nullptr not defined correctly, since it itself is not a pointer type (but there are transformations with NULL values ββof all pointer types).
See here ;
std::nullptr_t - null pointer literal type, nullptr . This is a separate type, which in itself is not a pointer type or a pointer to a member type.
In general, arbitrary pointer arithmetic (even to a NULL value) will almost certainly cause problems - you have not allocated this memory - you do not need to try to read or write.
For comparison purposes (for example, one by one) you will be fine, but otherwise the code you have will lead to undefined behavior.
Read more about Wikipedia's undefined behavior .
Niall source share