[Issue 3066] Array operation without a slice as the lvalue accepted, bad codegen

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 15 06:51:27 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3066


Kyle Foley <k-foley at onu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k-foley at onu.edu




--- Comment #1 from Kyle Foley <k-foley at onu.edu>  2009-07-15 06:51:21 PDT ---
I have recently discovered some bugs that are related to this

---

import std.stdio;

int main()
{
    int[] a = [1, 2, 3][];

    int[] b = a[] + 4;
    writeln("-> ", b); // -> 1 2 3 0 1935766371 1768515939 1764585331

    int[] c;
    c[] = a[] + 4;
    writeln("-> ", c); // -> 

    c = [1, 1, 1][];
    c[] = a[] + 4;
    writeln("-> ", c); // -> 5 6 7

    c = [0][];
    c[] = a[] + 4;
    writeln("-> ", c); // -> 5

    c = a[] + 4;
    writeln("-> ", c); // -> 1 2 3 0 1935766371 1768515939 1764585331

    int[3] d = a[] + 4; // this is ok
    writeln("-> ", d); // -> 5 6 7

    int[3] e = [1, 2, 3];
    int[3] f = [5, 6, 7];
    //writeln( "-> ", e[] + f[] ); // Compile Error -- Error: Array operation
e[] + f[] not implemented
    // yet, this works:
    writeln( "-> ", e.dup[] += f[] ); // -> 6 8 10

    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list