[Issue 12169] sum(int[]) should return a int
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 18 03:24:11 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12169
--- Comment #6 from bearophile_hugs at eml.cc 2014-02-18 03:23:57 PST ---
(In reply to comment #1)
> presumably to avoid overflow (which you are
> usually so concerned about, what changed?)
This after very few seconds of run time prints the wrong result
3028092401290448384 instead of 4_294_967_295 * 5_000_000_000 =
21474836475000000000:
struct Uints {
ulong count;
bool empty() { return count == 0; }
void popFront() { count--; }
uint front() { return uint.max; }
}
void main() {
import std.stdio, std.algorithm;
Uints(5_000_000_000).sum.writeln;
}
I think sum() should be changed to return an int before dmd 2.065final is
released.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list