Bug 8182 – with a lazy struct parameter, the struct's destructor is called on the generated delegate

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-01T15:52:00Z
Last change time
2012-10-26T04:45:48Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
nilsbossung

Comments

Comment #0 by nilsbossung — 2012-06-01T15:52:12Z
$ cat test.d import std.stdio; struct S { int x = 42; ~this() { if(x != 42) writeln((*cast(S delegate()*) &this)().x); } } void lazily(lazy S) { } void main() { lazily(S()); } $ rdmd test.d 42
Comment #1 by nilsbossung — 2012-06-10T16:57:41Z
Comment #2 by github-bugzilla — 2012-06-21T20:24:10Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7083076a06da8b43c3b515ac7ef0bd8330287f5d add lazy to the "don't destruct" list Lazy parameters are actually delegates. Calling the struct destructor on them was nonsense. This fixes issue 8182. https://github.com/D-Programming-Language/dmd/commit/009ce61ff416f1437e60c37d572c47878d694099 add a test for issue 8182 https://github.com/D-Programming-Language/dmd/commit/d313a470d78efd1995ef27dd37f64a66128bbc4c Merge pull request #995 from NilsBossung/bugzilla8182 fix Issue 8182 - with a lazy struct parameter, the struct's destructor is called on the generated delegate
Comment #3 by verylonglogin.reg — 2012-10-26T04:45:48Z
*** Issue 6167 has been marked as a duplicate of this issue. ***