Consider the following outline:
class Base { /* ... */ }; class Derived : public Base { public: void AdditionalFunctionality(int i){ /* ... */ } }; typedef
Does the Base has a virtual destructor? If yes then it is safe to use downcasting. In your incorrect sample pDerived should be NULL in result, so you need to check the result of dynamic_pointer_cast every time.
Base
pDerived
NULL
dynamic_pointer_cast