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
3 days ago 00:13:37 1
Elon CRUSHES the Swamp as NEW TRUMP ERA Takes Over DC!!!
3 days ago 00:00:43 1
Open a sea urchin to serve out of the shell!
3 days ago 00:04:19 1
“Табуретки“, Ансамбль “Школьные годы“. “Stools“, Ensemble “School Years“.
3 days ago 00:14:30 1
REPUBLICANS MIGHT NEVER LOSE POWER AGAIN!
3 days ago 00:23:16 1
UNWIND 20 Min Full Body Stretch Routine | Caroline Girvan
3 days ago 00:13:48 1
Sami Yusuf - One (When Paths Meet)
1 week ago 00:27:00 1
C’EST OFFICIEL ! LA PANDÉMIE VIENT D’UN LABORATOIRE DE WUHAN ! | GPTV INTERVIEW
1 week ago 00:03:00 1
The Offspring - The Kids Aren’t Alright (Official Music Video)
1 week ago 02:00:54 2
Syria Falls And No It’s Not A Good Thing | Candace Ep 116
1 week ago 00:24:57 16
K.C. Ayang Rinpoche Master of the Phowa
1 week ago 00:07:00 1
DINKA JESTER RR WIDEBODY - главный слив денег в обновлении “Agents of Sabotage“ в GTA Online
1 week ago 00:06:29 1
Kadebostany - Early Morning Dreams (Kled Mone Remix)
1 week ago 00:01:00 1
Иван Бортник в фильме “Убийство на Ждановской“, 1992. Clip. Custom. #shorts
2 weeks ago 00:06:44 5
Chick Corea - Spain (Duo by Elin Sandberg and Tracy Robertson)
2 weeks ago 00:03:27 1
2nd Mission: “MAVERICK“ | Starlight Boys EP07 Stage