Thread overview
[Issue 7579] New: disabled postblit called for array appending of Rvalues
Feb 25, 2012
dawg@dawgfoto.de
[Issue 7579] disabled postblit not checked for array appending
Feb 25, 2012
dawg@dawgfoto.de
Apr 20, 2012
SomeDude
Jul 02, 2012
Denis Shelomovskij
[Issue 7579] Disabled postblit ignored and not called by all array operations
Jul 02, 2012
Denis Shelomovskij
Jul 07, 2012
Kenji Hara
Oct 28, 2012
yebblies
February 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579

           Summary: disabled postblit called for array appending of
                    Rvalues
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dawg@dawgfoto.de


--- Comment #0 from dawg@dawgfoto.de 2012-02-25 02:54:27 PST ---
cat > bug.d << CODE
struct Foo
{
    version (none)
        @disable this(this);
    else // linker error if undefined
        @disable this(this) { assert(0); }
}

void main()
{
    Foo[] foos;
    foos ~= Foo(); // calls postblit
}
CODE

dmd -g bug

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 25, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579


dawg@dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|disabled postblit called    |disabled postblit not
                   |for array appending of      |checked for array appending
                   |Rvalues                     |


--- Comment #1 from dawg@dawgfoto.de 2012-02-25 02:57:09 PST ---
Appending Lvalues will give the same result even though it should be disabled.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com


--- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-04-20 02:10:02 PDT ---
Not sure I did the right thing, but I can't reproduce the error on Win32 2.059

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg@gmail.com


--- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-07-02 14:15:53 MSD ---
There is no linker/assert error any more. Once postblit is disabled it just silently not called. Very nasty.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|disabled postblit not       |Disabled postblit ignored
                   |checked for array appending |and not called by all array
                   |                            |operations
           Severity|normal                      |major


--- Comment #4 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-07-02 14:29:39 MSD ---
This compiles and runs successfully:
---
struct Foo
{
    // postblit can also have no body because isn't called
    @disable this(this) { assert(0); }
}

void main()
{
    Foo[3] sarr1, sarr2;
    sarr2 = sarr1;

    Foo[] darr1 = new Foo[3], darr2 = new Foo[3];
    darr2[] = darr1[];

    Foo s;
    darr1 ~= s;

    darr1 = darr1 ~ s ~ darr2;
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579



--- Comment #5 from Kenji Hara <k.hara.pg@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: -------
August 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579



--- Comment #6 from github-bugzilla@puremagic.com 2012-08-21 05:04:48 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/eee6c658ade142f84909503ba463bacecb7cfac9
fix Issue 7579 - Disabled postblit ignored and not called by all array
operations

https://github.com/D-Programming-Language/dmd/commit/d2ba7864be9fce3dc0626020ed8721f68ac7b9b2 Merge pull request #1037 from 9rnsr/fix7579

Issue 7579 & 8356 - Disable postblit ignored on array operation and return statement

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7579


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |FIXED
         AssignedTo|nobody@puremagic.com        |k.hara.pg@gmail.com


--- Comment #7 from yebblies <yebblies@gmail.com> 2012-10-28 22:49:38 EST ---
https://github.com/D-Programming-Language/dmd/pull/1037

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