Enumerate OOCP (undefined behavior) and what can and can't be checked for.

OOCP = Out Of Context Problem, aka Undefined Behavior.

May or may not be possible, but worth thinking about. Zig's issue on the matter is here: https://github.com/ziglang/zig/issues/2301

Assigned to
1 year, 2 months ago
7 months ago

Simon Heath 7 months ago ยท edit

The way I think about it there's two three types of UB:

There's the shit that breaks the assumptions that the compiler makes about the universe, like a wild pointer overwriting random parts of the stack. The compiler assumes that Just Doesn't Happen, checking for it at runtime would be hard and designing your language so it's impossible means taking out features that are useful.

Then in C/C++ there's the shit that the language committee can't agree on and so just calls it UB so implementations can do whatever they feel like. Like bit shifting negative numbers or calling realloc(NULL, 0).

I guess then there's the stuff actually there for optimization, like not defining what happens on integer overflow or infinite loop, which imo is probably never worth it.

The goal is to have none of the second and third type of UB, and minimize the first.

Register here or Log in to comment, or comment via email.