Get the latest tech news
How does Ada's memory safety compare against Rust?
A comparison of how well Rust and Ada prevent the most common memory-related software errors.
While Ada's controlled types do support implementing RAII-like functionality, under normal circumstances forgetting to manually deallocate heap memory will cause it to leak. If we wrap the Get call in a loop, and poll the user continuously until we have a value within the array bounds, SPARK can actually prove that a buffer overflow can't occur. Unlike in C, freeing an access type in Ada automatically sets its value to null, and any subsequent attempt to dereference it will raise a Constraint_Error exception, which can be caught and handled.
Or read this on Hacker News