Loading…
Subject: Security clear filter
arrow_back View All Dates
Thursday, September 17
 

14:00 MDT

Type Punning: the joke is on you, pun intended. Fixing UB of reinterpret_cast!
Thursday September 17, 2026 14:00 - 15:00 MDT
Many codebases contain several spots of type punning, and unfortunately a whole lot of those are incorrect and undefined behavior. While many current versions of compilers seem to do the correct thing, they might no longer do that tomorrow. Safety considerations wants to reduce/eliminate UB.

It might be worthwhile to inspect your reinterpret_cast constructs, most probably they are wrong. In this talk we will inspect what is wrong about those, we will learn about alignment, strict aliasing, object lifetime. 3 areas which might flag a red card on our type punning constructions.

Luckily the language evolved and gave us more tools to do it correctly, things like memcpy, memmove, bit cast, start lifetime_as, launder. It does however remain a dark corner and a dangerous territory to wander in. Because let's face it, zero copy is something we love in C++, and those bytes that came from the network, really are an array of integers, array of coordinates, ... Compiler, trust me, I know what I am doing. Am I?

Presenters
avatar for Lieven de Cock

Lieven de Cock

Founder, CppDriven
Lieven is a passionate software developer, architect, team lead, manager, coach, mentor, with 30 years of experience. He is passionate about C++, software craftsmanship, and clean code. His career started in the text-to-speech domain and then moved to video recognition technology... Read More →
Thursday September 17, 2026 14:00 - 15:00 MDT
Red Rock 8/9

15:15 MDT

The C++ safety issues your tools can't see
Thursday September 17, 2026 15:15 - 16:15 MDT
Much of the public criticism of C++ safety comes from vulnerabilities rooted in C patterns: raw pointer arithmetic, unchecked buffer indices, manual memory management. Modern C++ offers real answers to those problems through RAII, smart pointers, containers, and type-safe abstractions. But C++ also has its own distinct safety issues that have nothing to do with its heritage. Temporary lifetime rules that silently create dangling references. Iterator invalidation semantics that differ across containers in ways even experienced developers get wrong. Smart pointer ownership pitfalls that RAII cannot prevent. Coroutine frames that outlive their captured locals. Implicit conversions that turn a safe string into a dangling view between one line and the next. These are purely C++ problems. They compile cleanly, look correct in code review, and ship to production.

A survey of public CVE reports and security-fix commits across prominent open-source C++ projects shows the same patterns recurring again and again. This talk walks through those patterns, in code that looks correct in review, compiles cleanly, and then breaks at runtime. The session is aimed at intermediate-to-experienced C++ developers who already know modern C++ but want a working catalog of the subtle patterns that ship past typical code review.

Recognizing these patterns has long been the domain of library authors and security researchers. This talk distills a catalog from real-world fixes for everyone else: not a prescriptive standard like the Core Guidelines, but a pattern-recognition toolkit any C++ developer can apply in their next code review. The session also makes the case for expanding the community-level safety conversation to give these C++-unique patterns the same attention as the C-heritage debates.

Presenters
avatar for Ion Todirel

Ion Todirel

Lead Engineering Manager, Microsoft
I’m an engineering lead at Microsoft, building tools that make software development more accessible and boost productivity for millions of developers. I’m passionate about native code and C++.
Thursday September 17, 2026 15:15 - 16:15 MDT
Red Rock 8/9
 
Share Modal

Share this link via

Or copy link

Filter sessions
Apply filters to sessions.
Filtered by Date -