The C++ rvalue Lifetime Disaster - Arno Schoedl - C++ on Sea 2023
---
The C rvalue Lifetime Disaster - Arno Schoedl - C on Sea 2023
Rvalue references have been with us since C 11. They have originally been introduced to make moving objects more efficient: the object an rvalue reference references is assumed to go out of scope soon and thus may have its resources scavenged without harm. The C standard library, for example std::cref or std::ranges, makes use of yet another aspect of rvalue references: since they go out of scope soon, it is assumed unsafe to hold on to them beyond the scope of the current function, while lvalue references are considered safe. We, too, found this assumption to be very useful for smart memory management, in particular in generic code.
Unfortunately, the C language itself violates this assumption. Rvalues bind to const&. This means that innocent-looking functions silently convert rvalues to lvalue references, hiding any lifetime limitation of the rvalues. Temporary lifetime extension is meant to make binding a temporary to a reference safe by extending the lifetime of the temporary. But this only works as long as the temporary is a prvalue, and already breaks with rvalue references, let alone spuriously generated lvalue ones. These problems are not merely theoretical. We have had hard-to-find memory corruption in our code because of these problems. In this talk, I will describe the problems in detail, present our library-only approach to mitigate the problems, and finally, make an impossible-to-ever-get-into-the-standard proposal of how to put things right.
---
Slides:
Sponsored by think-cell:
---
Arno Schoedl
think-cell founder & CTO.
Arno is responsible for the development of all think-cell software products. He oversees our R&D team, quality assurance and customer care. Before founding think-cell, Arno worked at Microsoft Research and McKinsey. Arno studied computer science and management and holds a Ph.D. from Georgia Tech with a specialization in computer graphics.
---
C on Sea is an annual C and coding conference, in Folkestone, in the UK.
- Annual C on Sea, C conference:
- 2023 Program:
- Twitter:
---
YouTube Videos Filmed, Edited & Optimised by Digital Medium:
#cpp #cpponsea #cppprogramming
1 view
245
77
5 minutes ago 00:02:22 1
2025 Recap AI : Trump
9 minutes ago 00:52:29 1
[VF] Becoming Brigitte: Gaslighting The Public | Ep 1 - 04/02/2025 - #2
56 minutes ago 00:00:00 19
Becoming Brigitte: Gaslighting The Public | Ep 1
22 hours ago 01:11:57 29
EXCLUSIVE! Did Ryan Reynolds Extort Hollywood Execs? | Candace Ep 143
2 days ago 00:15:04 6
Украина Осталась БЕЗ ГАЗА! Удары России ДОСТИГЛИ ЦЕЛИ?
2 days ago 00:05:39 1
In This Moment - “The In-Between“ [OFFICIAL VIDEO]
2 days ago 00:54:00 57
Прохождение испытаний на время: JUNK ENERGY и RC BANDITO в GTA Online
3 days ago 00:20:21 1
Дисгармония в семейных отношениях. Кармические связи прошлых жизней/Часть 1
4 days ago 05:58:47 1
СМОТРИМ ВИДОСЯНЫ С @FORDMAC ПЕРЕД ОТПУСКОМ! (Реакционный стрим + ФОТОЖАБЫ) | ЗАКАЗ ОТКРЫТ
5 days ago 00:04:11 1
Il Volo - Your love - Once upon a time in the west (C’era una volta il west)
5 days ago 01:51:41 1
TATE BROS TAKE - MOATS with George Galloway - EP 417
6 days ago 00:45:04 1
ИСТОРИЯ ВСЕЛЕННОЙ APEX LEGENDS (Продолжение Titanfall 2, лор и сюжет) | ИгроСюжет (часть 1)
1 week ago 00:04:14 1
AliExpress Dummy Battery for Sony ZV-E10 Review - YouTube
1 week ago 00:00:00 2
CHINE - USA : LE CLASH FINAL ENTRE TRUMP ET XI JINPING | LAURENT MICHELON | GPTV
1 week ago 00:47:33 1
СРОЧНО! Берите Games Pass / DOOM The Dark Ages / Ninja Gaiden 4 / Expedition 33 / South of Midnight