www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14783] New: Overlapping Arrays with Binary Operations on Itself


          Issue ID: 14783
           Summary: Overlapping Arrays with Binary Operations on Itself
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.michael.hall gmail.com

The code below will not compile (on DMD 2.067.1) due to an overlapping array

void main()
    int[] x = [0, 1, 2];
    x[] *= x[];

Neither will it compile with x[] += x[];. 

Normally an overlapping error is when you try to do something like
x[1..$] *= x[0..$-1];
However, in this case, there is exact matching. The compiler should be able to
detect when it is a case like this and handle it appropriately.

Original discussion here:
http://forum.dlang.org/thread/xplooifwemzdtyigcnky forum.dlang.org

Jul 07 2015