Given that there is no reliable way to indicate which pointer points to compilation time, this is a rather difficult task that can be caught at compile time.
The easiest way is to make catch at run time using the safe_cast macro, which compiles into dynamic_cast using assert in debug and static_cast in version.
, , , NULL . , .