World Congress 2024

An (In-)Complete Guide to C++ Object Lifetimes

July 18, 2024 10:10 – 10:40 · 30 min STAGE 10 (120)

What this session covers

A C++ program manipulate objects, but it is undefined behavior if you attempt to manipulate them while they are not alive. So let’s do a deep dive into object lifetime.

When are objects created and when are they destroyed? How does temporary lifetime extension come into play and what changed there recently? What happens when you std::malloc memory and just pretend objects are there without creating anything? Or worse: You use mmap() to read shared memory. How do unions interact with constructors, strict aliasing, or the “common initial sequence”? What when you explicitly call the destructor and later re-use the same storage? What’s the deal with std::launder, std::bit_cast, and std::start_lifetime_as?

We’ll answer all of those questions and much more. We’ll do that by looking at the C++ standard, old and new proposals, and compiler optimizations.

Related talks at this congress

Open session

World Congress 2024

July 19, 2024 · 11:40–12:10

Virtual Stage 2

I implemented Game of Life 100+ times! Let's explore the 3 most interesting takes...

Ivett Ördög

Engineering culture advocate, public speaker, creator of a gamified devops training tool "Lean Poker"

Ivett Ördög
Open session

World Congress 2024

July 19, 2024 · 10:20–10:50

Virtual Stage 2

Are you done yet? Mastering long-running processes in modern architectures

Bernd Ruecker

Co-Founder and Chief Technologist

Bernd Ruecker
Open session

World Congress 2024

July 18, 2024 · 10:50–11:20

STAGE 10 (120)

Why Iterators Got It All Wrong — and what we should use instead

Arno Schoedl

think-cell founder & CTO

Arno Schoedl
Open session

World Congress 2024

July 19, 2024 · 09:40–10:10

STAGE 4 (500)

The Lifehacker's Guide to Software Architecture

Julian Lang

Solutions Architect, Amazon Web Services

Julian Lang
All sessions at this congress