man/checkers/dangerousTypeCast.md
Message: Potentially invalid type conversion in old-style C cast, clarify/fix with C++ cast
Category: Type Safety
Severity: Warning
Language: C++, not applicable for C code
C style casts can be dangerous in many ways:
This checker warns about old style C casts that perform type conversions that can be invalid.
This checker is not about readability. It is about safety.
You can use dynamic_cast or static_cast to fix these warnings.
Before:
struct Base{};
struct Derived: public Base {};
void foo(Base* base) {
Derived *p = (Derived*)base; // <- can be invalid
}
After:
struct Base{};
struct Derived: public Base {};
void foo(Base* base) {
Derived *p = dynamic_cast<Derived*>(base);
}