Thread overview
[Issue 8055] New: std.algorithm.move corrupts moved object field
May 07, 2012
Kenji Hara
[Issue 8055] [Regression 2.059] std.algorithm.move corrupts moved object field
May 07, 2012
Kenji Hara
May 07, 2012
Kenji Hara
May 08, 2012
Kenji Hara
May 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8055

           Summary: std.algorithm.move corrupts moved object field
           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 19:16:22 PDT ---
import std.algorithm;
struct S
{
    int x;
    ~this()
    {
        assert(x == 0);  // Line7
    }
}
S foo(S s)
{
    return move(s);
}
void main()
{
    S a;
    a.x = 0;
    auto b = foo(a);
    assert(b.x == 0);
}

-- 
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=8055


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.algorithm.move corrupts |[Regression 2.059]
                   |moved object field          |std.algorithm.move corrupts
                   |                            |moved object field
           Severity|normal                      |regression


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-06 19:27:29 PDT ---
Sorry, I accidentally posted that is only half written.

(In reply to comment #0)
> import std.algorithm;
> struct S
> {
>     int x;
>     ~this()
>     {
>         assert(x == 0);  // Line7
>     }
> }
> S foo(S s)
> {
>     return move(s);
> }
> void main()
> {
>     S a;
>     a.x = 0;
>     auto b = foo(a);
>     assert(b.x == 0);
> }

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

This regression is introduced this commit: https://github.com/D-Programming-Language/phobos/commit/71b1c1a

In unary move(), result is uninitialized. If T has an elaborate destructor, it is called on corrupted memory.

-- 
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=8055


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

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


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-06 20:38:49 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=8055



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

https://github.com/D-Programming-Language/phobos/commit/279963c9d0351809f1cab76f861af8a4832c1ec9 fix Issue 8055 - std.algorithm.move corrupts moved object field

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=8055


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: -------