by juxtaposec · 1y ago · 0 comments
IMHO, there are two undisputed properties that definitely should belong to memory safety, and they are good enough to spot "unsafe languages".
- Every memory access should be valid. You cannot read or write a pointer that is uninitialized, that points to a freed object, or that is beyond the boundary of the array, etc.
- Every memory access should be properly synchronized. This implies strictly controlled mutability.
These properties are _enforced_ by the compiler. In safe Rust, you cannot create a dangling pointer and dereference it. You also cannot create a data race by accident. But in C, C++, Zig, you can. In this sense, languages with managed memory are usually automatically memory safe.
No comments yet.