Type punning in modern C++

EN / День 1 / 15:30 / Зал 2

Type punning is often used in C++ for fast floating-point math, deserialising C++ objects from a sequence of bytes, and other purposes. Popular techniques involve unions, reinterpret_cast, and memcpy. C++20 provides new useful tools, such as bit_cast. And there are proposals to provide even better control over C++ object creation in the future.

This talk is a comprehensive overview of all of these techniques. We will discuss when and how they can be used safely without causing undefined behaviour, what C++ does and does not allow you to do (and why), existing holes in the C++ language, and how to fix them. In the process, we will cover important C++ concepts such as object lifetime, value representations, and aliasing rules.

Комментарий программного комитета:

Тимур известен своими чрезвычайно практичными и интересными докладами, в которых он всегда досконально изучает возможности языка и новых стандартов. Вспомните хотя бы доклад о всех вариантах инициализации в C++! На этот раз он подготовил подробный обзор техник type punning, от использующихся сейчас до новых возможностей из C++20.