www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21167] New: Please clarify the specification


          Issue ID: 21167
           Summary: Please clarify the specification
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: porton narod.ru

https://dlang.org/spec/arrays.html 12.9.4 "The slice on the left and any slices
on the right must not overlap."

Please clarify what this means and give an example of an error.

The following compiles and runs without errors despite left and right overlap
(in fact they are the same):

void main() {
  auto a = [3.0, 2.7, 3.4];
  auto b = [2.3, 1.4, 2.5];
  a[] = a[] + a[];

Is the above an undefined behavior? In this case, the spec should explicitly
mention undefined behavior and the compiler should give an error/warning.

Aug 16 2020