The C++ rvalue lifetime disaster. Arno Schödl ➠ CoreHard Autumn 2019
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 in at least two places. First, rvalues bind to const&. This means that innocent-looking functions taking a parameter by const& and passing it through in some way silently convert rvalues to lvalue references, hiding any lifetime limitation of the rvalues. std::min/max are two such examples. Worse still, every accessor member function returning a const& to a member suffers from this problem. Second, 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 still a prvalue. If the temporary has been passed through a function, even it has been correctly passed through by rvalue reference, lifetime extension will no longer be invoked and we get a dangling reference. 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.
Слайды: https://www.slideshare.net/corehard_by/the-c-rvalue-lifetime-disaster-arno-schodl-corehard-autumn-2019
Join CoreHard community:
CoreHard Telegram https://t.me/corehard_by
CoreHard Facebook https://www.facebook.com/corehard.by/
CoreHard Vkontakte https://vk.com/corehardby
CoreHard Instagram https://www.instagram.com/corehard.by/
Видео The C++ rvalue lifetime disaster. Arno Schödl ➠ CoreHard Autumn 2019 канала corehard
Слайды: https://www.slideshare.net/corehard_by/the-c-rvalue-lifetime-disaster-arno-schodl-corehard-autumn-2019
Join CoreHard community:
CoreHard Telegram https://t.me/corehard_by
CoreHard Facebook https://www.facebook.com/corehard.by/
CoreHard Vkontakte https://vk.com/corehardby
CoreHard Instagram https://www.instagram.com/corehard.by/
Видео The C++ rvalue lifetime disaster. Arno Schödl ➠ CoreHard Autumn 2019 канала corehard
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
I'm done with TypeScriptStorage Duration and Linkage in C and C++ - Dan SaksКак помочь и как помешать компилятору. Андрей Олейников ➠
CoreHard Autumn 2019Generators, Coroutines and Other Brain Unrolling Sweetness. Adi Shavit ➠
CoreHard Autumn 2019Защищая C++. Павел Филонов ➠ CoreHard Autumn 2019Google Coding Interview With A Competitive ProgrammerChoosing the Right Integer Types in C and C++ - Dan Saks - code::dive 2018The 1 Coding Project Idea Guaranteed To Get You A Software Development JobАвтоматизируй это. Кирилл Тихонов ➠
CoreHard Autumn 2019C++ Weekly - Ep 15 Using `std::bind`The 3 Myths of the Indian Education System | Vinay Menon | TEDxThiruvananthapuramC++Now 2018: Titus Winters “Modern C++ API Design: From Rvalue-References to Type Design”Статичный SQL в С++14. Евгений Захаров ➠
CoreHard Autumn 2019Steve Jobs introduces iPhone in 2007Back to Basics: Move Semantics (part 2 of 2) - Klaus Iglberger - CppCon 2019CppCast Episode 135: Think-Cell Ranges with Arno Schödla day in the life of a software engineerLearn Unreal Engine (with C++) - Full Course for BeginnersBack to Basics: Move Semantics (part 1 of 2) - Klaus Iglberger - CppCon 2019The science of skin color - Angela Koine Flynn