http://d.puremagic.com/issues/show_bug.cgi?id=7579



--- Comment #5 from Kenji Hara <k.hara...@gmail.com> 2012-07-07 08:01:15 PDT ---
(In reply to comment #1)
> Appending Lvalues will give the same result even though it should
> be disabled.

Even if the array element is a struct has disabled postblit, the concatinations
and appendings should be rejected statically by the compiler.

struct S
{
    // postblit can also have no body because isn't called
    @disable this(this) { assert(0); }
}
void main()
{
    S[] da;
    S s;
    da ~= s;   // 1. appending lvalue requires copying.
    da ~= S(); // 2. appending rvalue *also* requires copying
}

Why #2 should be rejected? Because, it might runs copying by the runtime...

    S[] da1 = new S[](3);
    S[] da2 = da1[0..1];
    assert(da2.capacity == 0);
    da2 = S(); // appending rvalue!
    assert(&da1[0] !is &da2[0]);
    // da1[0] is _copied_ by the runtime implicitly, but it breaks the
    // guarantees of the @disable postblit.

Therefore, we should reject *all* concatenation and appending of an array of
structs that has disabled postblit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to