Post

HN
Hacker News

Everything in C is undefined behavior

2026-05-19 , Categories: programming, security

If he had been a programmer, Cardinal Richelieu would have said โ€œGive me six lines written by the hand of the most expert C programmer in the world, and I will find enough in them to trigger undefined behaviorโ€.

Nobody can write correct C, or C++. And I say that as someone whoโ€™s written C and C++ on an almost daily basis for about 30 years. I listen to C++ podcasts. I watch C++ conference talks. I enjoy reading and writing C++.

C++ has served us well, but itโ€™s 2026, and the environment of 1985 (C++) or 1972 (C) is not the environment of today.

Iโ€™m definitely not the first to say this. I remember reading a post by someone prominent about a decade ago saying that a good case can be made that use of C++ is a SOX violation. And while I was not onboard with the rest of their rant (nor their confusion about โ€œitsโ€ vs โ€œitโ€™sโ€), I never disagreed about that point.

With time I found it to be more and more true. WAY more things are undefined behavior (UB) than youโ€™d expect.