This type of casting called upcasting is always safe.
An object of C can be cast to either A or B.

You should however use dynamic_cast 'cause it will check if the casting is valid.