[Issue 23112] code passes @nogc, allocates anyway

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 16 11:31:18 UTC 2022


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

Dennis <dkorpel at live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel at live.nl

--- Comment #1 from Dennis <dkorpel at live.nl> ---
An uninstantiated template generates no code, so here's the test modified a
bit:
```
 struct Forward(alias F) 
 {
    auto call()() 
    {
        return F();
    }
}

auto bar(int a) @nogc nothrow @safe 
{
    auto f()
    {
        return a;
    }
    return Forward!f();
}

extern(C) void main() @nogc 
{
    assert(bar(3).call() == 3);
}

```

Compile with -betterC and you get: undefined reference to '_d_allocmemory'

--


More information about the Digitalmars-d-bugs mailing list