Originally posted by piotrj3
View Post
Originally posted by piotrj3
View Post
Originally posted by piotrj3
View Post
Originally posted by piotrj3
View Post
Originally posted by piotrj3
View Post
Preventing use-after-free is not really a Rust thing. Freeing memory is part of the library, not language, so a C++ compiler could just as well special case the freeing functions, or use builtins to mark them as such. There are actually GCC function attributes you can use for this, btw. For example, __attribute__((__malloc__(...))).
The reason these are not Rust or language specific is because you can use external memory allocation functions, such as from Windows API, and they will have the same issues in Rust as they do in C++ without such compiler attributes. So that's not a point for Rust.
So far I only seen one benefit of Rust over C++ in terms of safety: moving invalidates the source object and lets the compiler know about it. This is a good thing, now let's hope GCC or Clang add it as an attribute or something to mark it as invalidated after a move constructor/assignment operator happens.
Comment