| ▲ | Sharlin 4 days ago | |||||||
-fsanitize-bounds uses a runtime address sanitizer, surely? The program compiles fine. In a (strongly) dependently typed language, something like the following would refuse to typecheck:
The type checker would demand a proof that i is in bounds, for example
In languages with an Option type this could of course be written without dependent types in a way that's still correct by construction, for example Rust:
But ultimately, memory safety here is only guaranteed by the library, not by the type system. | ||||||||
| ▲ | uecker 4 days ago | parent [-] | |||||||
You seem to be repeating what I said except you mixup strong and static typing. In a statically dependent-typed language you might expect it this not to compile, but this also depends. Run-time checking is certainly something you can combine with strong dependent typing. Implementing bounds checking that returns option types (which can also implement in C) is not exactly the same thing. But dependent typing can be more elegant - as it is here. | ||||||||
| ||||||||