www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12769] New: ICE returning array

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

          Issue ID: 12769
           Summary: ICE returning array
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

float[] f(float[] a)
{
    return -a[];
}

Internal error: e2ir.c 1834

DMD 2.065 w/ -m64



Here's what I was actually trying to do at the time:

float[4] f(float[4] a)
{
    return (-a[])[0..4];
}



Here's another permutation. It'd be nice if it could work out what '$' was at
compile time:

float[4] f(float[4] a)
{
    return (-a[])[0..$]; // use dollar instead of explicit '4'
}

Error: cannot implicitly convert expression ((-a[])[0..__dollar]) of type
float[] to float[4]



Ideally, this should work with static arrays:

float[4] f(float[4] a)
{
    return -a;
}

requiring a[] causes a to become a dynamic array, and then it can't be assigned
back to a static array anymore. It all goes south for array operations on
static arrays with [].

--
May 19 2014