Jump to page: 1 2
Thread overview
[Issue 17730] [scope][dip1000] std.algorithm.move escapes scope variable in @safe code
[Issue 17730] [scope][dip1000] Can escape references to scope classes via moving
Aug 07, 2017
Moritz Maxeiner
[Issue 17730] [scope][dip1000] Can escape references to scope classes by moving
Aug 07, 2017
Moritz Maxeiner
Aug 08, 2017
Mike
Aug 26, 2017
Walter Bright
[Issue 17730] [scope][dip1000] std.algorithm.move can escape references to scope classes
Aug 26, 2017
Walter Bright
Oct 23, 2017
Martin Nowak
Oct 23, 2017
Martin Nowak
Jan 03, 2018
Martin Nowak
August 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Moritz Maxeiner <moritz@ucworks.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, safe

--
August 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Moritz Maxeiner <moritz@ucworks.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[scope][dip1000] Can escape |[scope][dip1000] Can escape
                   |references to scope classes |references to scope classes
                   |via moving                  |by moving

--
August 08, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Mike <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--
August 26, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
          Component|dmd                         |phobos
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
Breaking it down to the following code:

import std.algorithm;

T moveImpl(T)(ref T source) {
    T result = void;
    moveEmplace(source, result);
    return result;
}

T trustedMoveImpl(T)(ref T source) @trusted {
    return moveImpl(source);
}

T move(T)(ref T source) {
    // test @safe destructible
    static if (__traits(compiles, (T t) @safe {}))
        return trustedMoveImpl(source); // this is the path taken
    else
        return moveImpl(source);
}

class A { }

A makeA() @safe {
        scope a = new A();
        return move(a);   // should fail
}

The trouble is that moveEmplace() is @system, but trustedMoveImpl() paints it
to be @trusted, thus defeating the scope checks.

Re-categorized as a Phobos issue.

--
August 26, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[scope][dip1000] Can escape |[scope][dip1000]
                   |references to scope classes |std.algorithm.move can
                   |by moving                   |escape references to scope
                   |                            |classes

--
October 23, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3
                 CC|                            |code@dawg.eu
            Summary|[scope][dip1000]            |[scope][dip1000]
                   |std.algorithm.move can      |std.algorithm.move escapes
                   |escape references to scope  |scope variable in @safe
                   |classes                     |code

--- Comment #2 from Martin Nowak <code@dawg.eu> ---
cat > bug.d << CODE
import std.algorithm : move;

int* escapeLocal() @safe
{
    int var;
    scope int* p = &var;
    return move(p); // should error
}

void test() @safe
{
    auto p = escapeLocal;
}
CODE
dmd -c -o- -dip1000 bug.d
----

Reduced example not specific to scope classes, seems like move should take it's argument as return scope, no?

--
October 23, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Martin Nowak <code@dawg.eu> ---
https://github.com/dlang/phobos/pull/5798

--
October 27, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/a34a25ead947fe6492fb0724b23dc5135c19ea1f fix Issue 17730 - move escapes scope variable in @safe code

- needs to be annotated with return scope, so that the return value
  lifetime depends on the argument's lifetime
- cannot be tested because phobos doesn't yet work with DIP1000 and
  also because of Issue 17932

https://github.com/dlang/phobos/commit/61b7b517b0ab2a3eed45116f7476a0bd7a68837a Merge pull request #5798 from MartinNowak/fix17730

fix Issue 17730 - move escapes scope variable in @safe code

--
October 27, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

github-bugzilla@puremagic.com changed:

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

--
December 18, 2017
https://issues.dlang.org/show_bug.cgi?id=17730

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/a34a25ead947fe6492fb0724b23dc5135c19ea1f fix Issue 17730 - move escapes scope variable in @safe code

https://github.com/dlang/phobos/commit/61b7b517b0ab2a3eed45116f7476a0bd7a68837a Merge pull request #5798 from MartinNowak/fix17730

--
« First   ‹ Prev
1 2