-
Notifications
You must be signed in to change notification settings - Fork 78
Description
https://clang.llvm.org/docs/BoundsSafety.html
There's a lot here if you include the runtime checks and new builtins but I think it can be handled in chunks - my suggestion would be that we start with a flag like -fexperimental-bounds-safety and add some of the easier attributes first (single, bidi_indexable, terminated_by, etc). counted_by / sized_by might need parser changes because it looks like they can refer "forward" to identifiers which aren't defined yet:
void foo(int *__attribute__((counted_by(count))) p, size_t count) { ... }This also adds compile time checking for certain types of pointers. For example single pointers can only be dereferenced or indexed with a constant value of 0.
Not all of the types will map cleanly to zig types - ended_by (pointer with another pointer as its upper bound) but this should allow us to translate things into Zig single pointers, slices, and sentinel-terminated slices.