www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16982] New: std.experimental.allocator.make!T must either

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

          Issue ID: 16982
           Summary: std.experimental.allocator.make!T must either call
                    GC.addRange or be marked  system
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: sludwig outerproduct.org

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().

--
Dec 18 2016