https://issues.dlang.org/show_bug.cgi?id=19916
Dennis <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #7 from Dennis <[email protected]> --- (In reply to Manu from comment #6) > Accessing uninitialised memory is absolutely a memory safety issue. Not per se. This compiles, prints a random number, and doesn't corrupt memory. ``` import std; void main() @safe { int a = void; writeln(a); } ``` > I don't know where this idea that it has strictly to do with pointers comes > from? > Why would safety be limited that way? Paraphrasing Walter from his DConf 2017 keynote, memory safety is not about 'no memory related bugs', it's "a concern in software development that aims to avoid software bugs that cause security vulnerabilities dealing with random-access memory (RAM) access, such as buffer overflows and dangling pointers". Uninitialized / overlapped pointers can cause such issues, uninitialized integers can not. Disallowing a simple harmless sum-type in @safe invites more use of @trusted giving more opportunities for actual memory corrupting bugs to creep in. Not to mention it would break existing code. Unless there is a way to actually corrupt memory in @safe code using this (without using @trusted) it's not something @safe should prevent. --
