Hacker News new | ask | show | jobs
by aeonik 409 days ago
Well theoretically if you compiled the whole system with Zig or Rust, you could eliminate that undefined behavior of invalid pointers right?

You'd need an OS that supports it, but it seems viable that the OS using allocators could know what happens at any given pointer.

To do it statically though, and with enough detail, I suppose it would take something like Idris with dependent types, and I'd imagine at that point it would be a pretty tough exercise.

1 comments

I think that'd require a different Datatype than a Raw pointer. Allocating heap memory is a side-effect that's not really predictable, if you take all the factors into account. However i can see a world where this may be possible because of virtual memory, but i don't know how.

Dependent Types could help, although i am unsure if it helps with raw pointers.