[Issue 17448] Move semantics cause memory corruption and cryptic bugs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 11 08:51:17 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=17448

--- Comment #33 from Shachar Shemesh <shachar at weka.io> ---
Like we said earlier, the safe implications are important, but are not the core
of this bug report.

The problem is that, as things stand with D, certain types of programming
become impossible.

For example, consider a RAII object protecting a resource (say, a file
descriptor). For debugging purposes, we want to have a version(debug) option
for tracking all such objects within the system.

Under C++, what we'd do is to have a global linked list head, and have each
RAII object register itself with the linked list in the constructor and
deregister itself in the destructor.

If necessary, we would have a move constructor that shifts the registration
when the RAII is moved.

This last step is impossible in D. You cannot be notified when the object
moves, and once it does, the global linked list will get completely corrupted.

--


More information about the Digitalmars-d-bugs mailing list