On Tuesday, 22 April 2014 at 18:34:47 UTC, Steven Schveighoffer wrote:
On Tue, 22 Apr 2014 14:17:57 -0400, Ali Çehreli <acehr...@yahoo.com> wrote:

I don't think there is slicing an rvalue though. (?) reduce() is taking a copy of the seed and then returning a slice to it because the user slices it in their lambda. It effectively does the following, which unfortunately compiles:

int[] foo()
{
    int[1] sum;
    return sum[];    // <-- no warning
}

It's not slicing an rvalue, but the above is trivially no different than:

In this case no, but;
//----
int[1] foo();
int[] a = foo();
//----
*is* slicing an rvalue, and it *does* compile. I don't think there needs to be escape analysis to catch this.

Reply via email to