http://d.puremagic.com/issues/show_bug.cgi?id=9335
--- Comment #9 from yebblies <[email protected]> 2013-06-29 00:55:21 EST --- (In reply to comment #8) > (In reply to comment #4) > > > > There is no need to call the destructor or postblit when moving the stack > > allocated structs to the heap, it is legal to move them with memcpy. > > Issue here is not in non-calling destructor when object is moved from stack to > heap by pointer but is in non-calling destructor for temporary. This > contradicts to policy in issue 9334 (which is itself not stable). > The temporary you are talking about is the struct that is being moved to the heap. D allows a struct to be moved with a memcpy. 9334 aside, what is happening here is valid. 1. Structs are constructed on the stack 2. Heap array space is allocated 3. Structs are bit-copied into the heap memory 4. The original stack structs are abandoned Because only one copy of the structs exists at the end, there is no copy, only a move. > General problem here is that dmd (unexpectedly) sometimes initializes > > variables > with temporaries and sometimes not. When it does initialize objects with a temporary, sometimes it calls destructors on it and sometimes not. Such game > with temporaries and destructors causes bugs. dmd is free to choose either making a copy (which means calling the postblit, then the destructor of the temporary) or to do a move (bitcopy) like it is doing here. The main difference is that a move has better performance. Both are valid. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
