~/talk

The dangers of C-style casts

Talkat CppCon 2015 · 2015-09-21..09-25· [c-and-cpp]
links:none on file
slides:none on file

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

~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.