Skip to content

Commit 832ace0

Browse files
authored
Merge pull request #6413 from edi33416/fix_i17806
Fix Issue 17806 - processAllocator getter will override set value if … merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>
2 parents 810ffe6 + 8d070a5 commit 832ace0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

std/experimental/allocator/package.d

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ module std.experimental.allocator;
226226
public import std.experimental.allocator.common,
227227
std.experimental.allocator.typed;
228228

229+
// Fix issue 17806: this should always be the first unittest in this module
230+
// in order to ensure that we use the `processAllocator` setter before the getter
231+
@system unittest
232+
{
233+
import std.experimental.allocator.mallocator : Mallocator;
234+
import std.experimental.allocator.gc_allocator : GCAllocator;
235+
auto newAlloc = sharedAllocatorObject(Mallocator.instance);
236+
processAllocator = newAlloc;
237+
assert(processAllocator is newAlloc);
238+
processAllocator = sharedAllocatorObject(GCAllocator.instance);
239+
}
240+
229241
// Example in the synopsis above
230242
@system unittest
231243
{
@@ -1058,10 +1070,10 @@ allocator can be cast to `shared`.
10581070

10591071
/// Ditto
10601072
@nogc nothrow @system
1061-
@property void processAllocator(RCISharedAllocator a)
1073+
@property void processAllocator(ref RCISharedAllocator a)
10621074
{
10631075
assert(!a.isNull);
1064-
_processAllocator = a;
1076+
processAllocator() = a;
10651077
}
10661078

10671079
@system unittest

0 commit comments

Comments
 (0)