http://d.puremagic.com/issues/show_bug.cgi?id=9704
Maxim Fomin <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Maxim Fomin <[email protected]> 2013-03-12 13:13:41 PDT --- (In reply to comment #0) > The problem is that the destructors are currently called in the callee but the > postblits in the caller. If an exception is thrown in between those calls, the > destructor can't be called. To be more precise, it happens during evaluation of function argument which follows some struct argument and throws exception. extern(C) int printf(const char* fmt, ...); struct A { this(this) { printf("A:this(this)\n");} ~this() { printf("A:~this\n"); } uint data; } int foo() { throw new Exception(""); } void func(A a, int i) {} void main() { A a; func(a, foo()); } Here should be two destructors: for "a" and " __cpcttmpXXX" structs. And calling dtor is unavoidable since postblit may deep copy some memory. > A possible solution is to move the destructor to the caller. But in this case > the parameter (the copy) must be passed by invisible reference so that the > destructor actually sees the updated value after the callee returns. > > (Note that it might be useful to make an exception for non-PODs without > destructors here. Those shouldn't be affected by this issue and could be > treated like PODs when being passed to a function as an optimization.) Alternatively a copy operation can be moved into callee or D runtime can be boosted to cope with such problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the issue.
