Thread overview
[Issue 14771] Hidden @nogc violation around closure creation
Jul 07, 2015
Kenji Hara
Aug 30, 2015
ag0aep6g@gmail.com
Dec 08, 2021
Stanislav Blinov
Dec 17, 2022
Iain Buclaw
July 07, 2015
https://issues.dlang.org/show_bug.cgi?id=14771

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
Issue 5730 is also related with the closure handling timing.

--
August 30, 2015
https://issues.dlang.org/show_bug.cgi?id=14771

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #2 from ag0aep6g@gmail.com ---
A variant is to make makeS a template instead of S.foo:

----
struct S(alias f)
{
    auto foo() { return f(0); }
}

auto makeS()() @nogc
{
    int x = 10;
    S!(a => x) s;
    return s;
}

void main() @nogc
{
    auto s = makeS();
}
----

Compiles, but shouldn't.

Some change in 2.068's Phobos makes it possible to accidentally do this with std.algorithm.map:

----
import std.algorithm: equal, map;
import std.range: only;

auto foo()(int[] a, immutable int b)
{
    return a.map!(x => x + b);
}

void main() @nogc
{
    int[3] test = [1,2,3];
    assert(test[].foo(3).equal(only(4,5,6)));
}
----

I've seen this twice recently:

http://forum.dlang.org/post/xpdntswucmqboejhxiit@forum.dlang.org http://forum.dlang.org/post/mrv0td$ci6$1@digitalmars.com

--
December 08, 2021
https://issues.dlang.org/show_bug.cgi?id=14771

Stanislav Blinov <stanislav.blinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.blinov@gmail.com

--- Comment #3 from Stanislav Blinov <stanislav.blinov@gmail.com> ---
Still an issue in 2.098.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14771

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
December 13
https://issues.dlang.org/show_bug.cgi?id=14771

--- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19012

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--