~/talk

Misusing reinterpret_cast?! You Probably Are :) (Keynote)

Talkat CppNorth 2025 · 2025-07-21..07-23· [compilers-and-language-design]
links:none on file
slides:none on file

reinterpret_cast often hides undefined behavior: strict aliasing violations, lifetime-start bugs when casting bytes to objects, unaligned accesses that can fault or cost ~10%, and surprising ABI-dependent results (int↔float bit-punning and bool reads differ between compilers). Practical fixes: prefer std::bit_cast for same-size reinterprets, use std::launder or memcpy/memmove to start lifetimes, prefer dynamic_cast/static_cast when possible, and run UB sanitizer in CI. A ready-made option exists as the Safe Casting Library that wraps these patterns safely.

AI-written summary · about

  1. 0:00Introduction and Context
  2. 3:51Storytelling and Survey
  3. 11:15Reinterpret Cast Basics
  4. 14:24Casting Rules and Aliasing
  5. 17:00Dynamic Cast vs Reinterpret Cast
  6. 22:33Strict Aliasing Pitfalls
  7. 27:52Floating Point and Integer Issues
  8. 30:35Bitcast and Type Sizes
  9. 31:40Boolean Representation Risks
  10. 33:39Memory Alignment Issues
  11. 37:19Safe Object Lifetime Management
  12. 41:05Lifetime Operations in C++20/23
  13. 46:03Summary and Best Practices
  14. 48:59Safe Casting Library Deep Dive
  15. 1:00:54Q&A Session
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.