Skip to content

Commit 9872d18

Browse files
committed
std.array.d: Use template `_d_newarrayU{,Trace}
dlang/dmd#21525 Adds the template `_d_newarrayUTrace`. To fix dlang/dmd#21033, this commit needs to replace the use of the non-template hook with the newly added template in `std.array.d`. Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
1 parent 30fcf07 commit 9872d18

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

std/array.d

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,14 +1073,6 @@ if (isDynamicArray!T && allSatisfy!(isIntegral, I))
10731073
}
10741074
}
10751075

1076-
// from rt/lifetime.d
1077-
private extern(C) void[] _d_newarrayU(const TypeInfo ti, size_t length) pure nothrow;
1078-
1079-
// from rt/tracegc.d
1080-
version (D_ProfileGC)
1081-
private extern (C) void[] _d_newarrayUTrace(string file, size_t line,
1082-
string funcname, const scope TypeInfo ti, size_t length) pure nothrow;
1083-
10841076
private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow
10851077
{
10861078
static assert(I.length <= nDimensions!T,
@@ -1131,18 +1123,19 @@ private auto arrayAllocImpl(bool minimallyInitialized, T, I...)(I sizes) nothrow
11311123
which will inform the GC how to destroy the items in the block
11321124
when it gets collected.
11331125
1134-
_d_newarrayU returns a void[], but with the length set according
1135-
to E.sizeof.
1126+
_d_newarrayU returns a E[], with the length set according to
1127+
to the size parameter.
11361128
+/
1129+
enum isShared = is (E == shared);
11371130
version (D_ProfileGC)
11381131
{
11391132
// FIXME: file, line, function should be propagated from the
11401133
// caller, not here.
1141-
*(cast(void[]*)&ret) = _d_newarrayUTrace(__FILE__, __LINE__,
1142-
__FUNCTION__, typeid(E[]), size);
1134+
ret = _d_newarrayUTrace!E(size, isShared,
1135+
__FILE__, __LINE__, __FUNCTION__);
11431136
}
11441137
else
1145-
*(cast(void[]*)&ret) = _d_newarrayU(typeid(E[]), size);
1138+
ret = _d_newarrayU!E(size, isShared);
11461139
static if (minimallyInitialized && hasIndirections!E)
11471140
// _d_newarrayU would have asserted if the multiplication below
11481141
// had overflowed, so we don't have to check it again.

0 commit comments

Comments
 (0)