Bug 18847 – std.allocator: Region uses .parent before it can be set

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-10T10:48:06Z
Last change time
2018-06-07T21:01:46Z
Keywords
pull
Assigned to
Vladimir Panteleev
Creator
Vladimir Panteleev

Comments

Comment #0 by dlang-bugzilla — 2018-05-10T10:48:06Z
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.
Comment #1 by dlang-bugzilla — 2018-05-15T03:39:07Z
Some goes for BitmappedBlock and KKRegion. ContiguousFreeList seems to have gotten this right (though with the end result of having 8 constructor declarations).
Comment #2 by dlang-bugzilla — 2018-05-15T23:02:26Z
Comment #3 by github-bugzilla — 2018-06-07T21:01:45Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/72b2128e6e5dbbc99464d0345fcd4c6692b078c3 Fix Issue 18847 - std.allocator: Region uses .parent before it can be set https://github.com/dlang/phobos/commit/f8a17a7898fd2a995f2f3fb1aac58f00f1ef827b Merge pull request #6508 from CyberShadow/pull-20180515-044632 Fix Issue 18847 - std.allocator: Region uses .parent before it can be set merged-on-behalf-of: Sebastian Wilzbach <[email protected]>