Bug 21923 – @live does not take destructor code into account.
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2021-05-15T13:05:29Z
Last change time
2024-04-15T21:46:30Z
Keywords
live, pull
Assigned to
No Owner
Creator
lempiji
Comments
Comment #0 by lempiji — 2021-05-15T13:05:29Z
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 by d.bugs — 2021-07-25T09:09:20Z
additionally there is a segfault (ICE) if you declare your variable using
```
scope t = Handle(10);
```
Comment #2 by dlang-bot — 2024-04-12T06:35:29Z
@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 by dlang-bot — 2024-04-15T21:46:30Z
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