Get the latest tech news

Type Punning in C and C++


I had a bug that took me a while to track down. The problem was type punning. A pointer cast worked fine at -O0 and silently broke at -O2. The C vs C++ distinction here is genuinely treacherous, and most blog posts on the topic get it wrong.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of type

type

Related news:

News photo

Stabilizing Rust's Never Type

News photo

Researcher reverse-engineers infamous Stuxnet malware source code, publishes it on Github for all — attack targeted Iranian nuclear facilities and was the first software of its type to cause physical damage

News photo

New GTA 6 details reveal a 'Bonnie and Clyde-type' narrative, life sim systems, and the ability to seamlessly swap between Jason and Lucia during gameplay