Thread overview
[Issue 8057] New: std.algorithm.move cannot use for nested struct
May 07, 2012
Kenji Hara
May 07, 2012
Kenji Hara
May 08, 2012
Kenji Hara
Nov 03, 2012
Denis Shelomovskij
Nov 03, 2012
Denis Shelomovskij
May 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8057

           Summary: std.algorithm.move cannot use for nested struct
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: k.hara.pg@gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-06 20:31:19 PDT ---
import std.algorithm;
void main()
{
    int n = 10;
    struct S
    {
        int x;
        ~this()
        {
            // Access to enclosing scope
            assert(n == 10);    // Line11
        }
    }
    S foo(S s)
    {
        // Move nested struct
        return move(s);
    }
    S a;
    a.x = 1;
    auto b = foo(a);
    import core.stdc.stdio;
    printf("a.x = %d\n", a.x);
    assert(b.x == 1);
}

output:
----
core.exception.AssertError@test(11): Assertion failure

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-06 20:39:21 PDT ---
https://github.com/D-Programming-Language/phobos/pull/572

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



--- Comment #2 from github-bugzilla@puremagic.com 2012-05-08 10:14:42 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/dc6fb32f8749138ec9304c8e5e1b009b5d5dcb2e fix Issue 8057 - std.algorithm.move cannot use for nested struct

https://github.com/D-Programming-Language/phobos/commit/892038953dfd645952a482a06f692ea6fba2f437 Merge pull request #572 from 9rnsr/fix_move

Issue 8055 & 8057 - Fix std.algorithm.move issues

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


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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-11-03 22:35:32 MSK ---
S's destructor is incorrect, as you always can set `S s = S.init` and the destructor must process that correctly. Corrected destructor variant:

---
 ~this()
 {
+    // Struct always can equal to its `init`      <- added
+    if(this == S.init) return;                    <- added
     // Access to enclosing scope
     assert(n == 10);    // Line11
 }
---

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



--- Comment #4 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-11-04 00:13:50 MSK ---
(In reply to comment #3)
> S's destructor is incorrect, as you always can set `S s = S.init`...

And also because of `destroy` existance.

This behavior is fixed in https://github.com/D-Programming-Language/phobos/pull/923

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