[Issue 11159] New: [CTFE] Integer exponentiation give incorrect values
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 2 16:31:55 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11159
Summary: [CTFE] Integer exponentiation give incorrect values
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: CTFE, patch
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: safety0ff.bugz at gmail.com
--- Comment #0 from safety0ff.bugz at gmail.com 2013-10-02 16:31:54 PDT ---
Example program:
import std.stdio;
void main() {
writeln("==== Runtime ====");
ulong ten = 10, two = 2;
writeln(two^^63);// ok
writeln(two^^64);// overflows -> 2^64 % 2^64
writeln(ten^^18);// ok
writeln(ten^^19);// ok
writeln(ten^^20);// overflows -> 10^20 % 2^64
writeln("==== CTFE ====");
enum ulong eten = 10, etwo = 2;
writeln(etwo^^63);// ok
writeln(etwo^^64);// expect an overflow, gives 2^63
writeln(eten^^18);// ok
writeln(eten^^19);// should work, gives 2^63 instead (2^63 > 10^19)
writeln(eten^^20);// expect an overflow, gives 2^63
}
See attached patch for proposed fix.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list