The dangers of C-style casts
summary
Demonstrates that using C-style casts lets the compiler silently perform dangerous conversions that lead to undefined Behavior: an apparently innocent cast compiles but using the result triggers UB, while replacing it with static_cast makes the code fail to compile and prevents the bug. Shows a forward-declared struct case where a C-style cast drops const on a float-to-pointer scenario, and explains the cast resolution order — const_cast then static_cast then reinterpret_cast — plus the one narrow exception (casting to a private base), arguing to prefer explicit C++ casts.
AI-written summary · about
related talks
54mTypical C++, But Why?
51mTypical C++, but Why?
01h 05mType Punning in C++17: Avoiding Pun-defined Behavior
52mNon-conforming C++: the Secrets the Committee Is Hiding From You
01h 33mDe-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable
05mDetecting Programs That Rely on Undefined Behavior
01h 26mC++ Under the Hood: (Internal Class Mechanisms)
01h 13mType safe C++ – LOL! :-)
