On 3/1/18 3:06 PM, ag0aep6g wrote:
On Thursday, 1 March 2018 at 19:05:26 UTC, Steven Schveighoffer wrote:
Yes it behaves just like array bounds. No it's not well-defined if you disable asserts.

Right. So it's defined to throw an Error in @safe code, and it has undefined behavior in @system code. The spec should say this.

No.

----
version(dosafe)
{
    void main() @safe
    {
        int[4] arr;
        arr[0 .. 3] = arr[1 .. 4];
    }
}
else
{
    void main()
    {
        int[4] arr;
        arr[0 .. 3] = arr[1 .. 4];
    }
}
---

dmd -version=dosafe -noboundscheck -run testarrayoverlap.d => no error, undefined behavior
dmd -run testarrayoverlap.d => error

@safe has nothing to do with it.

-Steve

Reply via email to