[Issue 18847] New: std.allocator: Region uses .parent before it can be set
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu May 10 10:48:06 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=18847
          Issue ID: 18847
           Summary: std.allocator: Region uses .parent before it can be
                    set
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net
                CC: andrei at erdani.com
Here is one constructor of
std.experimental.allocator.building_blocks.region.Region:
    static if (!is(ParentAllocator == NullAllocator))
    this(size_t n)
    {
        this(cast(ubyte[])(parent.allocate(n.roundUpToAlignment(alignment))));
    }
If parent has state, then there is no way to set it before it is used in the
constructor.
There is a workaround: copy the contents of the constructor of the invoking
code, then use the constructor taking a buffer, and only then initialize the
parent. This is sub-ideal.
The constructor(s) should probably accept a parent argument as needed, or the
object should support deferred initialization.
--
    
    
More information about the Digitalmars-d-bugs
mailing list