Ranges and @safe
Paul Backus
snarwin at gmail.com
Sun Sep 22 23:18:12 UTC 2019
On Sunday, 22 September 2019 at 23:03:32 UTC, SrMordred wrote:
> I think that .front in ranges should'nt be safe by default.
>
> @safe{ iota(0,0).front(); } //BOOM, but compiles on @safe.
@safe does not mean "does not have runtime errors", it means
"does not corrupt memory". Accessing the front of an empty range
may crash your program, but it shouldn't cause memory corruption
(unless you disable bounds-checking).
More information about the Digitalmars-d
mailing list