HN Hall of Fame Weekly email

Undefined behavior in C is a reading error

www.yodaiken.com Essays & writing Essays & articles Software engineering Candidate
Screenshot of www.yodaiken.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 2 calendar years, with breakout response in 2 of them.

submissions
4
submitters
4
observed span
2021–2024
peak thread · 491 comments
203 pts
latest 20+ return · 2024-09-02
25 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

Because there seems to be some confusion in this thread: - "Implementation-defined behavior" means that the C standard specifies the allowable behaviors that a C implementation must choose from, and the implementation must document its particular choice. - "Unspecified behavior" means that the C standard places no particular restrictions on the behavior, but a C implementation must pick a behavior and document its choice. - "Undefined behavior" means that C implementations are allowed to assume that the respective…

layer8·203-point thread·

TFA is misunderstanding. As he cites from the C standard, “Undefined behavior gives the implementor license not to catch certain program errors that are difficult to diagnose.” Since it’s difficult (and even, in the general case of runtime conditions, impossible at compile time) to diagnose, the implementor (compiler writer) has two choices: (a) assume that the undefined behavior doesn’t occur, and implement optimizations under that assumption, or (b) nevertheless implement a defined behavior for it, which in many…

layer8·25-point thread·

Unfortunately you have to choose what you want your C compiler to be. It can be little more than a macro assembler that preserves "the obvious" behavior of undefined constructs on the target platform. Most compilers will do this by default (-O0). Or you can opt into using an optimizing compiler (-O2). But when optimization passes ignore the possibility of undefined behavior with unpredictable results (as explicitly allowed by the standard), you get, well, unpredictable results. Nowadays compilers even offer…

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
2

100+ points or 50+ comments

Total points
239

reference only — not used in Hall rules or ranking

Total comments
562

reference only — not used in Hall rules or ranking

Every submission

DateTitle as submittedByPointsComments
2021-05-19Undefined behavior in C is a misinterpretation of the Standardvyodaiken20
2021-05-20Undefined behavior in C is a reading errorr4um94
2021-05-20Undefined behavior in C is a reading errorFirst breakout · Best threadzdw203491
2024-09-02Undefined behavior in C is a reading error (2021)Latest 20+ point returnnequo2567