Everything in C is undefined behavior

Programmers are spiraling as C gets called a giant trap full of invisible mistakes

TLDR: The article argues that C and C++ are so full of hidden traps that even experts can accidentally write broken programs. Commenters immediately turned it into a brawl over technical details, with some demanding proof, some acting unimpressed, and others gatekeeping who counts as a “real” C++ programmer.

A programming essay declaring that basically all serious C and C++ code hides dangerous “undefined behavior” lit the comments on fire, and honestly, the crowd reaction is the real show. The writer’s big claim is simple but brutal: these old-school languages are packed with invisible footguns, and even experienced developers can write code that looks fine but may fail, crash, or act weird on different machines. In plain English: the computer may not do what the human thought it asked for, and the rules are so slippery that blame gets fuzzy fast.

But the comment section was not in a “wow, scary” mood for long. It instantly split into factions. One camp went full fact-check mode, with readers pouncing on a specific example and basically yelling, “Cite the rule!” Another camp shrugged with the energy of a bored meme reply: “Ok, and?” Then came the classic language-war snobbery, with one commenter sneering that anyone saying “C/C++” together probably doesn’t really know modern C++ at all. Ouch.

There was also nerd-comedy, because no internet fight is complete without it. One commenter tossed in the infamous i = i++ chestnut like a cursed inside joke, while another pasted the official standard’s definition of undefined behavior like they were entering courtroom evidence. The vibe? Half existential crisis, half pedantic cage match, with a side of “this is why programming people can never just have one opinion.”

Key Points

  • The article argues that undefined behavior is pervasive in nontrivial C and C++ code and that even experienced programmers cannot reliably avoid it.
  • It says undefined behavior includes not only familiar memory-safety problems like double-free and use-after-free, but also subtler cases programmers may overlook.
  • The article states that undefined behavior is not only about optimization settings; compilers are allowed to assume code is valid regardless of whether optimizations are enabled.
  • It uses misaligned `int*` dereferencing as an example, citing C23 6.3.2.3 and describing different outcomes on Alpha, SPARC, and x86/amd64 systems.
  • The article argues that because compilers are not required to handle undefined cases, code that seems to work on one architecture or compiler version may fail on another.

Hottest takes

"please cite the spec section explaining that this is UB" — dmitrygr
"Ok, and?" — nokeya
"Anyone who uses the construction \"C/C++\" doesn’t write modern C++" — stackghost
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.