[Issue 15932] Get rid of the implicit slicing of static arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 4 18:51:38 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=15932

--- Comment #1 from hsteoh at quickfur.ath.cx ---
Explicit code example illustrating this problem:
-----
struct S {
        int[] data;
        this(int[] _data) { data = _data; }
}
S makeS() {
        int[5] data = [ 1, 2, 3, 4, 5 ];
        return S(data);
}
void func(S s) {
        import std.stdio;
        writeln("s.data = ", s.data);
}
void main() {
        S s = makeS();
        func(s);
}
-----

Expected output:
-----
s.data = [1, 2, 3, 4, 5]
-----

Actual output (YMMV, depends on details of stack implementation on your
platform):
-----
s.data = [-580467872, 32764, 1617267003, 21973, 5]
-----

--


More information about the Digitalmars-d-bugs mailing list