Thread overview
Why LDC drop d_with_sum code? (windows)
May 28, 2019
KnightMare
May 28, 2019
Dennis
May 28, 2019
KnightMare
May 28, 2019
https://forum.dlang.org/post/zpqkgldjlozfnmsveqkn@forum.dlang.org

DMD & LDC change d_with_sum(...) to "return .0"
why?

PS I use LDC most time so asking here not in DMD
May 28, 2019
On Tuesday, 28 May 2019 at 10:43:38 UTC, KnightMare wrote:
> DMD & LDC change d_with_sum(...) to "return .0"
> why?

Because you are summing an empty array.

```
double d_with_sum(double[] values) @safe pure nothrow
{
    import std.algorithm : sum;
    double[] squares;
    squares[] = values[] * values[];
    return squares.sum;
}
```

`squares` is initialized with length and pointer 0, and the values[] * values[] gets truncated to the size of the destination memory, so it becomes a no-op.
May 28, 2019
>> DMD & LDC change d_with_sum(...) to "return .0"
>> why?
>
> Because you are summing an empty array.
> `squares` is initialized with length and pointer 0, and the values[] * values[] gets truncated to the size of the destination memory, so it becomes a no-op.

yep. thx.
C:\content\downloadz\dlang>times2.exe
t1=42 ms, 929 ╬╝s, and 1 hnsec          r=109226661546_74544967680
t2=42 ms and 578 ╬╝s                    r=109226661546_74544967680
t3=333 ms, 539 ╬╝s, and 3 hnsecs        r=109226661546_66672259072
t4=42 ms, 631 ╬╝s, and 9 hnsecs         r=109226661546_74544967680

now I have not small diff but probably double math..