Skip to content

Commit ddf5567

Browse files
committed
Merge pull request #1305 from dymk/ctfe-array
fix for calling .array() on ranges in CTFE
2 parents e54288b + 5294809 commit ddf5567

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

std/array.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ if(allSatisfy!(isIntegral, I))
318318

319319
alias typeof(T.init[0]) E;
320320

321-
auto ptr = cast(E*) GC.malloc(sizes[0] * E.sizeof, blockAttribute!(E));
321+
auto ptr = (__ctfe) ?
322+
(new E[](sizes[0])).ptr :
323+
cast(E*) GC.malloc(sizes[0] * E.sizeof, blockAttribute!(E));
322324
auto ret = ptr[0..sizes[0]];
323325

324326
static if(sizes.length > 1)

0 commit comments

Comments
 (0)