[Issue 18529] .ptr on arrays can no longer be used in @safe code prevents valid code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 27 12:48:50 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18529
ag0aep6g at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ag0aep6g at gmail.com
--- Comment #9 from ag0aep6g at gmail.com ---
(In reply to Timothee Cour from comment #0)
> NOTE: the rationale for that deprecation was that the pointer can't be
> dereferenced. However that's no different from the following:
> class A{...}
> A a;
> // valid in safe code even though `a` is null and can't be derefenced.
Because no one seems to have addresses this so far:
Null dereferences are considered @safe. A null dereference is assumed to lead
to a segfault which stops the program, preventing memory corruption.
The problem with `.ptr` isn't null. The problem is that the pointer can be
invalid despite not being null.
--
More information about the Digitalmars-d-bugs
mailing list