D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22919 - [dip1000] -checkaction=context gives "assigned to `__assertOp2` with longer lifetime"
Summary: [dip1000] -checkaction=context gives "assigned to `__assertOp2` with longer l...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull, safe
Depends on:
Blocks:
 
Reported: 2022-03-24 13:35 UTC by Dennis
Modified: 2022-03-28 08:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dennis 2022-03-24 13:35:58 UTC
```
@safe:
struct S
{
    int* p;
    ref S get() scope return {return this;}
}

unittest
{
    int[3] sArr;
    scope S arr = S();
    assert(arr == arr.get());
}
```
Compile with:
> dmd -preview=dip1000 -checkaction=context test.d

Gives:

> scope variable `arr` assigned to `__assertOp2` with longer lifetime
Comment 1 moonlightsentinel 2022-03-24 21:55:43 UTC
Probably related to the numerous STC.temp hacks found in escape.d. `__assertOp2` is generated as an explicit temporary whose lifetime is restricted to the statement
Comment 2 Dlang Bot 2022-03-25 15:56:14 UTC
@dkorpel created dlang/dmd pull request #13888 "Fix Issue 22919 - -checkaction=context gives "assigned to `__assertOp…" fixing this issue:

- Fix Issue 22919 - -checkaction=context gives "assigned to `__assertOp2` with longer lifetime"

https://github.com/dlang/dmd/pull/13888
Comment 3 Dlang Bot 2022-03-28 08:13:31 UTC
dlang/dmd pull request #13888 "Fix Issue 22919 - -checkaction=context gives "assigned to `__assertOp…" was merged into master:

- a791ebcb33b2033f73eec353886ddc25181e2b74 by Dennis Korpel:
  Fix Issue 22919 - -checkaction=context gives "assigned to `__assertOp2` with longer lifetime"

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