~/talk

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

Talkat NDC TechTown 2024 · 2024-09-09..09-12· [c-and-cpp]
links:none on file
slides:none on file

Claims the C++ standard has mistakes and walks through concrete rules: when declarations, new/placement new, memcpy/bit_cast, or std::start_lifetime_as actually begin lifetimes; how temporary lifetime extension and range-for rules extend temporaries; why pointer provenance (not just address) makes some pointer arithmetic UB; when std::launder fixes provenance after placement new; memcpy/bit_cast as the safe type‑punning path; and that C++26 downgrades some UB to erroneous to curb optimizations. Practical advice: prefer placement new/start_lifetime_as or unions, and avoid relying on implicit object creation.

AI-written summary · about

  1. 0:00C++ object lifetimes intro
  2. 6:22Variable declarations storage
  3. 11:35Dynamic allocation new/delete
  4. 12:36Temporary objects lifetime
  5. 18:08Placement new manual control
  6. 27:57Replacement transparency
  7. 33:12Implicit object creation
  8. 37:59Pointer provenance
  9. 44:58Type punning reinterpret_cast
  10. 51:22Type punning techniques
  11. 55:18Guidelines summary
~/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.