It's not unsafe as in "memory segmentation fault" unsafe.
It's unsafe as in, if you don't follow the rules, the resulting value is ~rand().
For those familiar with C/C++ terminology, this is the tame "unspecified behavior" (not the nasal demon "undefined behavior.")