[Issue 22331] spec is incorrect regarding interfacing C with GC and local variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 22 21:56:59 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22331
--- Comment #2 from Steven Schveighoffer <schveiguy at gmail.com> ---
(In reply to anonymous4 from comment #1)
> Umm, the stack advice is solid, you just apparently conflate lifetime with
> lexical scope.
How would you leave a pointer on the stack?
This doesn't work:
------
void foo()
{
auto c = new Class; // not on the stack
c.method(); // c still not stored on the stack.
GC.collect(); // possibly will collect c.
}
------
The recommendation in the spec is to use a "parameter or automatic variable".
This doesn't work. If the recommendation is to store on the stack is solid, it
should provide a solid mechanism to do so.
--
More information about the Digitalmars-d-bugs
mailing list