Rule Definition
Avoid using static_cast on pointers because static_cast does not do any run time checking of the types involved, which means that unless you know what you are doing, they could be very unsafe. Consider replacing use of static_cast with its more powerful relative dynamic_cast. There is an overhead in doing so, but it is not worth taking the risk of using static_cast.
Remediation
Use dynamic_cast.
Violation Code Sample
class B {};
class D : B {};
B* b = new B();
D* d1 = static_cast<D*>b; // Invalid! => VIOLATION
D* d2 = dynamic_cast<D*>b; // Valid, but d2 is now a null pointer
Now d1 will point to a data segment of type D*, but the actual data is B*, and will lead to memory issues and corruption. d2 on the other hand will be a null pointer and can be checked for and handled correctly.
Reference
http://msdn.microsoft.com/en-us/library/c36yw7x9(VS.80).aspx
http://my.safaribooksonline.com/0321113586/ch93
http://stackoverflow.com/questions/28002/regular-cast-vs-staticcast-vs-dynamiccast
http://codeidol.com/cpp/cpp-coding-standards/Avoid-using-static_cast-on-pointers/
Related Technologies
C++
Technical Criterion
Programming Practices - OO Inheritance and Polymorphism
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.