Not a compiler bug.
mw
mingwu at gmail.com
Thu Aug 13 18:20:17 UTC 2020
On Thursday, 13 August 2020 at 09:25:07 UTC, John Colvin wrote:
> Personally I would love to be able to disallow implicit
> signed-to-unsigned conversions in almost all cases, but that
> would be a big breaking change.
At least I want a warning message, even with a turn-on
command-line switch is fine, I personally will turn it on all the
time, silently performing this conversions is horrible.
I spent half of the night yesterday to trace down the issue.
https://run.dlang.io/is/je8L4r
==================================
import std.algorithm;
import std.stdio;
void main() {
long[] a = [-5000, 0];
long c = sum(a) / a.length;
writeln(c); // output 9223372036854773308
}
==================================
In contrast, there was a compiler warning message for loop index
https://run.dlang.io/is/4Sqc5n
onlineapp.d(4): Deprecation: foreach: loop index implicitly
converted from size_t to int
More information about the Digitalmars-d
mailing list