~/talk

An (In-)Complete Guide to C++ Object Lifetimes

Talkat ACCU 2024 · 2024-04-17..04-20· [c-and-cpp]
links:none on file
slides:none on file

Covers exact rules that decide whether a C++ object is alive: when definitions, new/placement new, memcpy/memmove/malloc or mmap implicitly or explicitly start lifetimes, and when destructors or storage reuse end them. Explains temporary lifetime extension gotchas, when to use std::launder versus std::bit_cast, and how std::start_lifetime_as lets you treat raw bytes as objects. Shows compiler optimizations (provenance, strict aliasing) that make naive malloc/mmap, union punning, or pointer arithmetic undefined and how these cause surprising concurrency and optimization traps; gives concrete fixes and language-version notes (C++26 change).

AI-written summary · about

  1. 0:00C++ object lifetimes intro
  2. 1:15Objects and lifetimes
  3. 9:16Variable declarations
  4. 15:20Dynamic allocation
  5. 16:46Temporary objects
  6. 24:30Placement new
  7. 36:36Implicit object creation C++20
  8. 41:11Start lifetime explicit
  9. 48:24Pointer semantics
  10. 58:25Type punning rules
  11. 1:07:10Zombie pointers
  12. 1:18:34Summary guidelines
~/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.