When creating objects that contain references, make() doesn't currently call GC.addRange(), which may lead to dangling references in case the GC frees such an unseen reference.
To fix this, make() must either be marked as @system as soon as an object with references is created, or preferably, it should call GC.addRange(). A vanilla version ("makeNoGC"?) could be added to be able to opt-out of this, but it should be very clear from its name that it is unsafe in a GC scenario, because this is a pitfall that is very easy to hit.
The same reasoning applies to makeArray().
Yeah, I used to simply `static if (std.traits.hasIndirections!T) GC.addRange(...);` in vibe.d's allocator module. Using annotations instead of controlling this at the call site is an interesting idea, although I can see applications for both approaches.
Using @nogc sounds good, too, although if that approach is taken, I'd propose to define @nogc as a UDA in object.d instead of adding a new special trait for detecting its presence.
Comment #3 by greeenify — 2016-12-27T11:36:10Z
*** Issue 15790 has been marked as a duplicate of this issue. ***