Bug 5737 – postblit not called for locals initialized from ref functions
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-03-15T01:54:00Z
Last change time
2012-05-07T19:40:20Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
samukha
Comments
Comment #0 by samukha — 2011-03-15T01:54:18Z
struct S
{
static int destroyed;
static int copied;
this(this)
{
copied++;
}
~this()
{
destroyed++;
}
}
S s;
ref S foo()
{
return s;
}
void main()
{
{
auto s2 = foo();
}
assert(S.copied == 1); // fail, s2 was not copied;
assert(S.destroyed == 1); // ok, s2 was destroyed
}
The destructor is called on s2, though s2 has not been postblit(ted?).
Maybe the same as other struct lifetime bugs.
Comment #1 by kiithsacmp — 2012-03-18T02:45:08Z
Confirmed to still happen with DMD 2.058 .
Comment #2 by k.hara.pg — 2012-05-04T23:30:37Z
*** Issue 8045 has been marked as a duplicate of this issue. ***