Issue 21923 - @live does not take destructor code into account.
Summary: @live does not take destructor code into account.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P3 minor
Assignee: No Owner
URL:
Keywords: live, pull
Depends on:
Blocks:
 
Reported: 2021-05-15 13:05 UTC by lempiji
Modified: 2024-04-15 21:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description lempiji 2021-05-15 13:05:29 UTC
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

```
Comment 1 Jan Jurzitza 2021-07-25 09:09:20 UTC
additionally there is a segfault (ICE) if you declare your variable using

```
scope t = Handle(10);
```
Comment 2 Dlang Bot 2024-04-12 06:35:29 UTC
@WalterBright created dlang/dmd pull request #16371 "fix bugzilla Issue 21923 - @live does not take destructor code into a…" fixing this issue:

- fix bugzilla Issue 21923 - @live does not take destructor code into account

https://github.com/dlang/dmd/pull/16371
Comment 3 Dlang Bot 2024-04-15 21:46:30 UTC
dlang/dmd pull request #16371 "fix bugzilla Issue 21923 - @live does not take destructor code into a…" was merged into master:

- 2774d0e9cf3f86a8b3604862b970b2a8c0f88e10 by Walter Bright:
  fix bugzilla Issue 21923 - @live does not take destructor code into account

https://github.com/dlang/dmd/pull/16371