~/talk

The C++ rvalue Lifetime Disaster

Talkat C++ on Sea 2023 · 2023-06-28..06-30· [c-and-cpp]
links:none on file
slides:none on file

C++ lets rvalues bind to const&, which silently lies about lifetime and produces real dangling references and hard-to-find memory corruption in deployed code. Mitigations shown: a library-only autocrf macro that decays rvalues into owned values when needed, deleting rvalue-qualified accessors, and a custom common_reference wrapper to avoid spurious copies. A hypothetical pragma for new binding rules is proposed to flip binding direction in new code, but practical fix today is the macro-based, source-level workaround.

AI-written summary · about

  1. 0:00Introduction
  2. 0:47Rvalue Lifetime
  3. 4:12Named Return Value Optimization
  4. 6:02No Named Return Value Optimization
  5. 6:50A Special Case
  6. 8:05Recommendations
  7. 8:39Temporary Lifetime Extension
  8. 9:07Generic Code
  9. 9:35Lifetime Extension
  10. 10:39Example
  11. 14:20The problem
  12. 15:31The solution
  13. 17:04Declaration type
  14. 17:25Autocrf
  15. 17:50Autocrf const
  16. 18:56Autocrf rvalue
  17. 19:24Accessors
  18. 21:27C
  19. 25:57What C does
  20. 27:40We made a mess
  21. 27:59Warning
  22. 28:11Requirements
  23. 28:40Reference Binding
  24. 30:38Trying it out
  25. 32:12Impact on the standard library
  26. 33:01Mitigations
  27. 33:36Member Accessors
  28. 35:39Conclusion
~/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.