Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 192b7ba

Browse files
Merge pull request #2705 from skoppe/arraycast-fix
Make TempStringNoAlloc a template
2 parents 035859b + 12f046d commit 192b7ba

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/core/internal/string.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ char[] unsignedToTempString()(ulong value, return scope char[] buf, uint radix =
5353
return buf[i .. $];
5454
}
5555

56-
private struct TempStringNoAlloc
56+
private struct TempStringNoAlloc()
5757
{
5858
// need to handle 65 bytes for radix of 2 with negative sign.
5959
private char[65] _buf = void;
@@ -79,7 +79,7 @@ Returns:
7979
*/
8080
auto unsignedToTempString()(ulong value, uint radix = 10) @safe
8181
{
82-
TempStringNoAlloc result = void;
82+
TempStringNoAlloc!() result = void;
8383
result._len = unsignedToTempString(value, result._buf, radix).length & 0xff;
8484
return result;
8585
}

test/betterc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include ../common.mak
22

3-
TESTS:=test18828 test19416 test19421 test19561
3+
TESTS:=test18828 test19416 test19421 test19561 test20088
44

55
.PHONY: all clean
66
all: $(addprefix $(ROOT)/,$(addsuffix ,$(TESTS)))

test/betterc/src/test20088.d

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*******************************************/
2+
// https://issues.dlang.org/show_bug.cgi?id=20088
3+
4+
struct S {
5+
int i;
6+
}
7+
8+
extern(C) int main() @nogc nothrow pure
9+
{
10+
S[2] s = [S(1),S(2)];
11+
void[] v = cast(void[])s;
12+
S[] p = cast(S[])v; // cast of void[] to S[] triggers __ArrayCast template function
13+
return 0;
14+
}

0 commit comments

Comments
 (0)