~/talk

The C++ rvalue Lifetime Disaster

Talkat ACCU 2021 Online · 2021-03-10..03-13· [c-and-cpp]
links:none on file
slides:none on file

C++ lets const& silently bind rvalues and a prvalue bound through a function loses lifetime extension, causing real dangling references and memory corruption in production code. Evidence: std::min/std::max and accessor returns turn temporaries into long-lived const&; passing a prvalue through forwarding breaks lifetime extension. Built mitigations are library-only: an autoCRef macro that decays temporaries to values, a custom common_reference and ternary wrapper, and deleted rvalue accessor overloads; these mitigations are used successfully, while a full language fix remains unimplemented.

AI-written summary · about

  1. 0:00Start
  2. 5:39Rvalue References for Moving - Pitfalls
  3. 12:19Temporary Lifetime Extension vs. Rvalues
  4. 22:55C++ Rvalue Amnesia
  5. 26:04Conditional Operator Afraid of Rvalue Amnesia
  6. 27:27C++20 common_reference Not Afraid
  7. 29:30Promises of References
  8. 34:19Reference Declarations (2)
  9. 36:14Impact on Standard Library
  10. 39:21Summary
~/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.