~icefox/garnet#50: 
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

Status
REPORTED
Submitter
~icefox
Assigned to
No-one
Submitted
1 year, 11 months ago
Updated
6 months ago
Labels
T-LATER

Simon Heath 1 year, 4 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.

~icefox 8 months ago

Types And Programming Languages (Pierce, 2003)

...a safe language is one that protects its own abstractions.

Simon Heath 6 months ago · edit

Very simple but very important distinction, thanks rpjohnst: "rust considers it a bug when safe code can have ub"

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