[Issue 6186] New: Struct destructor is not called on out parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 20 18:31:11 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6186
Summary: Struct destructor is not called on out parameter
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-06-20 18:26:25 PDT ---
An object typed T through out parameter is initialized by T.init (like memcpy),
but its destructor is not called before initializing.
----
int dtor_cnt;
struct S
{
int n;
~this(){ dtor_cnt++; }
}
void test1()
{
void f1(out S s){}
S s = S(1);
dtor_cnt = 0;
f1(s);
assert(dtor_cnt == 1); // NG
}
void test2()
{
void f2(out S[2] sa){}
S[2] sa = [S(1), S(2)];
dtor_cnt = 0;
f2(sa);
assert(dtor_cnt == 2); // NG
}
void main()
{
test1();
test2();
}
----
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list