@nogc inconsistent for array comparison depending on mutability of elements

rcorre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 7 18:36:18 PDT 2016


@nogc unittest {
     int[2] a = [1, 2];
     assert(a == [1, 2]); // OK

     immutable(int)[2] b = [1, 2];
     assert(b == [1, 2]); // fail: array literal may cause 
allocation
}

Is there any logic behind allowing the comparison with `a` but 
not `b`, or is this a compiler bug?


More information about the Digitalmars-d-learn mailing list