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
243
77
1 week ago 00:12:07 1
Let’s talk about the Environment! Environment Vocabulary Essential for IELTS, TOEFL, CELPIP, EIKEN!
1 week ago 00:03:45 1
Mira - Dragostea Nu Se stinge (Global Session)
1 week ago 00:05:52 1
U. D. O. - Cry Soldier Cry (Russian Version)
1 week ago 00:03:37 1
Goodbye June - Good Side
1 week ago 00:04:37 1
Roxette – Spending My Time (Official Video) [Remastered ℗ 2021]
1 week ago 00:11:32 1
9 проблем с кожей, указывающие на сахарный диабет 👀
1 week ago 00:19:35 1
Как выжить россиянам: всё дорожает, а труд дешевеет | Санкции, инфляция и курс доллара
1 week ago 02:05:33 1
(NO ADS) Soothing Music to Calm Your Hyperactive, Anxious Cat and Help with Sleep! Music for Cats
1 week ago 00:09:54 1
Короткометражка «Прости, мама\Forgive me mom» | Подготовлено DeeaFilm
1 week ago 00:14:46 1
I shrink 10x every 21s until I’m an atom - The Micro Universe
1 week ago 00:09:55 1
Naomi Klein: We need an exodus from Zionism
1 week ago 00:04:42 1
DIY Mobile Stand | How To Make Stand At Home | Homemade Mobile Stand | Phone Stand
1 week ago 00:02:08 1
Poison - Hazbin Hotel OST (Pop Punk + Metal Cover) / Zephyrianna
1 week ago 00:06:28 1
【Honkai: Star Rail】 OST 「Hope Is the Thing With Feathers」 Uplifting Trance Remix
1 week ago 00:03:54 1
HELLOWEEN - Forever And One (Neverland) (Official Music Video)
1 week ago 00:03:11 1
The Blue Stones - Black Holes (Solid Ground) (Official Music Video)
1 week ago 00:04:15 1
Bring Me The Horizon - Shadow Moses (Official Video)
1 week ago 00:06:28 1
Namash - Digital Ghost
1 week ago 00:04:51 1
【6人合唱】Paintёr (RUS)【HBD, SAVI!】
1 week ago 00:30:42 1
В чём смысл Пеппи? (сравнение разных версий)
1 week ago 00:05:46 1
Northlane - Dante [Official Music Video]
1 week ago 00:03:54 3
SAVAGE-44 - Never look back ♫ Dj Eurodriver & Flanga mix 2024 ♫
1 week ago 00:03:51 1
PESTILENCE - Suspended Animation (Live The Karnival Fest 2019)
1 week ago 00:04:51 1
DAGOBA - The Hunt (Official Video) | Napalm Records