Everything in C is undefined behavior

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

A 30-year C/C++ veteran argues that undefined behavior (UB) is so pervasive in C and C++ that no programmer, no matter how expert, can reliably avoid it. The post walks through numerous non-obvious UB examples: misaligned pointer access, casting uint8_t* to int*, passing char to isxdigit(), float-to-int conversion, null pointer semantics, variadic argument type mismatches, and integer promotion surprises. The author contends UB is not just a compiler optimization concern but a fundamental semantic gap — the compiler simply has no way to express the programmer's intent. The post concludes that LLMs are now better than humans at spotting UB, and that writing C/C++ in 2026 without LLM-assisted review is arguably irresponsible, citing findings in OpenBSD's codebase as evidence.

12m read timeFrom blog.habets.se
Post cover image
Table of contents
It’s not about optimizationsUB is everywhereDivide by zero is UBBonus non-UBLLMs are better than us at thisSo what do we do now?Related
47.7K Impressions1 Comment