Thread overview
[Issue 17804] Accessing `enum' or `static' member allocates gc closure
Mar 16, 2019
asumface@gmail.com
Dec 17, 2022
Iain Buclaw
March 16, 2019
https://issues.dlang.org/show_bug.cgi?id=17804

asumface@gmail.com changed:

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

--- Comment #1 from asumface@gmail.com ---
To add to this, consider the following code:

import std.algorithm;
struct Foo
{
    static int fun(int n)
    {
        return n + 1;
    }
}

void main()
{
    int[10] arr;
    Foo foo;
    arr[].map!(n => foo.fun(n));
}

the line
    arr[].map!(n => foo.fun(n));
causes GC allocation, whereas the same line with foo replaced with its type
    arr[].map!(n => Foo.fun(n));
does not. This is despite the functionality being absolutely identical as fun
has no dependency on 'this' whatsoever due to being a static member.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

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

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

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

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

--