On Tuesday, 6 March 2018 at 07:11:24 UTC, Jonathan M Davis wrote:
That example actually should be perfectly @safe, because the
array is null, and it's using writeln. Dereferencing null is
@safe, because it segfaults and thus can't corrupt memory or
access invalid memory. You obviously don't want it to happen,
but it's @safe. Also, passing a pointer to writeln is fine,
because it's just going to print the value, so that's @safe
too, even if the pointer value is garbage.
my point had nothing to do with writeln.
my point was, that a RangeError exception may help save the day,
but not when you use .ptr
thankfully Steven gave a much better example to make the point
(I assume that int is meant to be size_t)