[Issue 21923] New: @live is not detect destructor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 15 13:05:29 UTC 2021


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

          Issue ID: 21923
           Summary: @live is not detect destructor
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Keywords: live
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: lempiji at gmail.com

Hi, I want fully @live annotated library.

I had hoped that this code would detect RAII correctly.
If it is not supported, then I think the compiler should ignore this error.

How about it?

https://run.dlang.io/is/cIHt7V

```
import core.stdc.stdlib;

@live:

struct Handle
{
    private void* _handle;

    @disable this();
    @disable this(this);

    this(int n)
    {
        _handle = malloc(n);
    }

    ~this()
    {
        free(_handle);
    }
}

void main()
{
    auto t = Handle(10); // The result is the same even if it is `scope`
}
```

```
onlineapp.d(25): Error: variable `onlineapp.main.t` is left dangling at return

```

--


More information about the Digitalmars-d-bugs mailing list