www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19447] New: [REG2.066] fixed size slice assignment in ctfe

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

          Issue ID: 19447
           Summary: [REG2.066] fixed size slice assignment in ctfe loses
                    connection with array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: CTFE, wrong-code
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dfj1esp02 sneakemail.com

---
bool f()
{
    int[3] a=1;
    assert(a[0]==1);
    g(a[0..2]);
    assert(a[0]!=1); //fails
    assert(a[0]==2);
    return true;
}
void g(ref int[2] a)
{
    int[2] b=2;
    a=b;
    assert(a[0]==2);
}
static assert(f());
---
The feature was apparently introduced in 2.063 and worked until 2.066.
Works with explicit array operation a[]=b[];

--
Nov 29 2018