Bug 22919 – [dip1000] -checkaction=context gives "assigned to `__assertOp2` with longer lifetime"

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-24T13:35:58Z
Last change time
2022-03-28T08:13:31Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2022-03-24T13:35:58Z
``` @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 by moonlightsentinel — 2022-03-24T21:55:43Z
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 by dlang-bot — 2022-03-25T15:56:14Z
@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 by dlang-bot — 2022-03-28T08:13:31Z
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