[Issue 16394] TypeInfo.init() for static arrays returns single element instead of whole array

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Aug 15 15:25:13 PDT 2016


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

--- Comment #1 from Eyal <eyal at weka.io> ---
As a result, std.algorithm:initializeAll is also buggy:

import std.stdio;
unittest {
    struct Int {
        ~this() {}
        int x = 3;
    }
    import std.algorithm : initializeAll;
    Int[2] xs = [Int(1), Int(2)];
    struct R {
        bool done;
        bool empty() { return done; }
        ref Int[2] front() { return xs; }
        void popFront() { done = true; }
    }
    writeln(xs);
    initializeAll(R());
    writeln(xs);
}

Prints out:
[Int(1, 7FE7FED92000), Int(2, 7FE7FED92000)]
[Int(3, null), Int(0, 73)]

The second field being printed for Int seems like *yet another* bug.

--


More information about the Digitalmars-d-bugs mailing list