Comment

Comment by torstenvl

> it would be better if programmers read deliberate instances of UB as if they literally said "std::unreachable()"

Except that isn't true.

There are basically two kinds of undefined behavior.

The first is undefinable behavior, the kind that easily goes disastrously wrong, like writing to random memory locations.

The second is incidentally undefined behavior, something where there just isn't enough implementation consensus for the standard to settle on it, like realloc(p, 0).

There's no standard terminology I'm aware of to distinguish the two. But the distinction exists.

And where programmers read deliberate instances of UB, it's usually the latter, e.g., writing directly to an address memory mapped to device I/O in that particular environment.

parent torstenvl 7 days ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton