Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 16, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Susan <su+dlangissues@angel-island.zone> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |su+dlangissues@angel-island | |.zone -- |
May 16, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Dennis <dkorpel@live.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dkorpel@live.nl --- Comment #1 from Dennis <dkorpel@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' -- |
June 04, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |betterC CC| |bugzilla@digitalmars.com -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> --- (In reply to Dennis from comment #1) > auto call()() Rewriting as: > auto call() and it gives the error: test2.d(8): Error: function `test2.bar` is `@nogc` yet allocates closures with the GC test2.d(10): test2.bar.f closes over variable a at test2.d(8) which is what we expect. The trouble with the template version is the semantic3() of bar() should run the semantic3() of Forward.call, which is necessary to discover that bar() requires a closure. But it does not do the semantic3() of Forward.call until after semantic3() for bar() has completed. -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |safe -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- Some further study. The semantic analysis for call()() cannot be done during the semantic analysis for bar() or Forward, because the template arguments to call()() are as yet unknown. We only find out the arguments when main() takes the return value (an instance of Forward) and calls it. To fix this, the argument `f` supplied to the parameter `alias F` of `Forward` must be regarded as escaping when the instance of `Forward` is returned from `bar()`. Not doing this is a major hole in the @safe system. -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=23160 -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 --- Comment #4 from Walter Bright <bugzilla@digitalmars.com> --- A simpler version of this is filed as https://issues.dlang.org/show_bug.cgi?id=23160 which should be fixed first. -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> --- @WalterBright created dlang/dmd pull request #14183 "fix Issue 23112 - code passes @nogc, allocates anyway" fixing this issue: - fix Issue 23112 - code passes @nogc, allocates anyway https://github.com/dlang/dmd/pull/14183 -- |
June 05, 2022 [Issue 23112] code passes @nogc, allocates anyway | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23112 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=14730 -- |
Copyright © 1999-2021 by the D Language Foundation