Thread overview
[Issue 19993] Reference to delegate after return statement causes unnecessary closure allocation
Sep 29, 2019
Paul Backus
Dec 17, 2022
Iain Buclaw
September 29, 2019
https://issues.dlang.org/show_bug.cgi?id=19993

--- Comment #1 from Paul Backus <snarwin+bugzilla@gmail.com> ---
This also affects delegates passed as arguments to template sequence parameters. A reference to a different, non-delegate element of the same sequence parameter can cause a closure to be allocated, as in the following example:

---

auto call(Args...)() {
    return Args[0]();
    pragma(msg, typeof(Args[1]));
}

@nogc void main() {
    int acc = 0;
    call!(() => acc += 1, "hello");
}

---

As before, if the pragma(msg) is moved before the return statement in `call`, the program compiles and runs without error.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

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

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

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

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

--