[Issue 20869] New: `std.algorithm.mutation : move` is overly trusting of `opPostMove`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 28 10:30:30 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20869

          Issue ID: 20869
           Summary: `std.algorithm.mutation : move` is overly trusting of
                    `opPostMove`
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Keywords: safe
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: pro.mathias.lang at gmail.com

```
import std.algorithm.mutation;

struct S
{
    void opPostMove(const ref S old) @system nothrow pure
    {
        int* ptr = cast(int*)42;
        *ptr = 42;
    }
    int a;
}


void main () @safe nothrow
{
    S s1;
    s1.a = 41;
    S s2 = move(s1);
    assert(s2.a == 42);
}
```

--


More information about the Digitalmars-d-bugs mailing list