[Issue 4791] Assigning a static array to itself should be allowed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jun 6 00:40:34 PDT 2014


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

--- Comment #5 from bearophile_hugs at eml.cc ---
(In reply to David Simcha from comment #2)
> Yes, and this is a nightmare for generic code.

A recent bug in my code (I have used a loop to avoid the overhead of calling
the runtime function):


void main() {
    int[3] a, b, c;
    foreach (immutable i; 0 .. a.length)
        c = a[i] + b[i];
}


The correct foreach body is instead:

c[i] = a[i] + b[i];


So I think there are disadvantages at not requiring a [] syntax for all
array-wide operations.

--


More information about the Digitalmars-d-bugs mailing list