You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Function _d_newarraymTX is internally used for expressions like `new int[][](2, 3)`. The function is @trusted, but it can be called with more dimensions at runtime than the type has:
```import std.stdio;void main() @safe{ auto a = _d_newarraymTX!(int*[][], int)([1, 1, 42]); writeln(a); // prints [[42]]}```
The function internally allocates an array with the dimensions `[1][1][42]`, but then returns it as type `int*[][]`. The length of the inner array is now interpreted as a pointer.
See also the discussion in https://github.com/dlang/dmd/pull/16400
A solution could be to change the function signature to this:
```Tarr _d_newarraymTX(Tarr : U[], size_t N, U)(size_t[N] dims, bool isShared=false) @trusted```
The text was updated successfully, but these errors were encountered:
Tim reported this on 2024-04-19T20:23:01Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24514
Description
The text was updated successfully, but these errors were encountered: