D not considered memory safe
Walter Bright
newshound2 at digitalmars.com
Wed Jul 3 18:03:52 UTC 2024
On 7/2/2024 9:30 PM, Steven Schveighoffer wrote:
> Well, the article is wrong that having a GC prevents all memory safety problems.
>
> What causes all the problems (mostly) is the "built-in memory management" of the
> stack, and critically, returning references to stack data that will outlive the
> stack frame.
The compiler protects against that. Give it a try!
> Having a GC isn't enough, every single memory allocation scheme
> must also be safe to have a safe language.
To be memory safe, you'd have to use the GC instead of malloc/free. Using the
stack is ok.
> What I would say with D is that it is *much easier* to be memory safe, and the
> compiler provides tools to help with this.
D does much better than that if one sticks with @safe code and the GC.
More information about the Digitalmars-d
mailing list