@live questions

Dukc ajieskola at gmail.com
Thu Nov 26 13:17:00 UTC 2020


On Thursday, 26 November 2020 at 13:07:38 UTC, Dukc wrote:
>
> Huh? Won't that make the compiler to think the programmer is 
> leaking the pointer when it exits the scope? If I understood 
> correctly, `@live` requires freeing any non-null `int*`, or 
> forwarding them to a function that takes them as non-scoped 
> `int*`.

Or do you mean one has to do this:

```
void leak(T)(T* ptr){}

@live void useGc()
{  auto ptr = new int(5);
    writeln(*ptr);
    ptr.leak;
}
```
?

Now when I think of it, it might make some sense. You obviously 
do not want this when all memory is garbage-collected or 
intentionally leaked. But if one has to use `free()` it might be 
worth the additional hassle.


More information about the Digitalmars-d mailing list