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
202
65
5 months ago 00:16:12 1
41 No Gi Open Guard Concepts In Just 16 Minutes By Jason Scully BJJ Grappling
5 months ago 00:03:10 1
Slimane - Mon Amour | France 🇫🇷 | Official Music Video | Eurovision 2024
5 months ago 01:21:28 1
[NK NOW ONLY] Kim goes the extra mile to court Putin during 21-hour-long visit
5 months ago 00:03:20 1
Music B - My Breath (Dance Version 2024)
5 months ago 00:11:12 1
CLEANSES from Everything BAD in 10 minutes (VERY MUCH) Burn DAMAGE, EVIL EYE, INSULTS and CURSES
5 months ago 00:04:04 1
SAVAGE-44 - Falling into fantasy ♫ Hot Dance HiT 2024 ♫
5 months ago 00:00:51 2
Retro Generals Trailer
5 months ago 00:02:02 1
Barcelona Guitar Trio & Dance - Billie Jean (Homenaje a Paco de Lucía) New version
5 months ago 00:47:54 1
Оркестр Поля Мориа Сборник Лучших Мелодий Paul Mauriat Collection of the Best Melodies
5 months ago 00:06:53 1
Kabhi Alvida Naa Kehna Lyric Video - Title Song|Shahrukh,Rani,Preity,Abhishek|Alka Yagnik
5 months ago 00:20:07 1
Путин в Северной Корее и Вьетнаме: Запад в бешенстве
5 months ago 00:15:28 1
4 Biggest Propeller Myths Explored - Long vs Short & 2 vs 3 Blade
5 months ago 01:57:15 1
Вьетнам: от Хошимина до Нячанга | Крысы, электромобили и фейковый коммунизм
5 months ago 00:03:37 1
DNDM - Jasmine (Original Mix)
5 months ago 00:10:35 1
Все варианты ответов Аманды! Аманда путешественница 2 | Amanda 2 All variants (Demo)