Why do common C++ features like `std::min` and the ternary operator create dangling references? This talk reveals a fundamental language flaw and how to fix it.
#1about 3 minutes
The dual role of rvalue references in C++
Rvalue references were introduced for move semantics to avoid copies but are also used to manage the lifetime of temporary objects.
#2about 6 minutes
Why temporary lifetime extension fails in modern C++
The pre-C++11 feature for extending temporary object lifetimes does not work correctly with rvalue references, necessitating a custom macro to create a value or reference based on expression type.
#3about 6 minutes
How accessor methods cause rvalue amnesia
Standard accessor methods returning a const lvalue reference incorrectly bind to rvalues, losing critical lifetime information and leading to dangling references.
#4about 4 minutes
A proposal for fixing C++ reference binding rules
A proposed language fix using pragmas would introduce new, safer reference binding rules to prevent short-lived rvalues from binding to long-lived lvalue references.
#5about 3 minutes
Practical mitigations for rvalue lifetime issues today
Use custom macros to manage variable lifetimes, guard member accessors, and implement a correct ternary operator to work around the language's flawed binding rules.
#6about 1 minute
Managing C++ complexity with strong coding guidelines
The best way to manage the growing complexity of C++ is to establish strong internal coding guidelines and use custom libraries to standardize code patterns.
Related jobs
Jobs that call for the skills explored in this talk.
Matching moments
05:02 MIN
Understanding temporary objects and lifetime extension rules
An (In-)Complete Guide to C++ Object Lifetimes
07:52 MIN
Modern C++ evolution and the burden of backward compatibility
Eternal Sunshine of the Spotless Programming Language
07:50 MIN
Using modern language features for safer code
C++ in constrained environments
01:58 MIN
Implicit destruction and best practices for object lifetime
An (In-)Complete Guide to C++ Object Lifetimes
06:50 MIN
C++ availability, ecosystem, and backwards compatibility
101 brilliant things of C++
03:06 MIN
Defining objects and lifetimes in C++
An (In-)Complete Guide to C++ Object Lifetimes
08:47 MIN
Q&A on language design, Rust, and the future of C++
The Design and Evolution of C++
05:58 MIN
Reviewing common memory safety problems in other languages
4 reasons why you should learn Rust in 2021 – and maybe even have fun doing itRust is considered complex and a programming language with a steep learning curve. That's one side of the medal. We mention four points that Rust has ahead of other programming languages in terms of user-friendliness. Rust is a modern programming lan...
Panel Discussion: Responsible AI in Practice - Real-World Examples and ChallengesIntroductionIn the ever-evolving landscape of artificial intelligence, the concept of "responsible AI" has emerged as a cornerstone for ethical and practical AI implementation. During the WWC24 Panel discussion, three eminent experts—Mina, Bjorn Brin...
Chris Heilmann
All the videos of Halfstack London 2024!Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
From learning to earning
Jobs that call for the skills explored in this talk.