www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11159] New: [CTFE] Integer exponentiation give incorrect values

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: safety0ff.bugz gmail.com


--- Comment #0 from safety0ff.bugz 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: -------
Oct 02 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11159



--- Comment #1 from safety0ff.bugz gmail.com 2013-10-02 16:32:46 PDT ---
Created an attachment (id=1255)
Proposed fix

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11159



--- Comment #2 from safety0ff.bugz gmail.com 2013-10-02 22:18:12 PDT ---
Patch fixes issue 7548, one issue should be marked duplicate of the other.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 02 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11159


safety0ff.bugz gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #3 from safety0ff.bugz gmail.com 2013-10-03 07:52:33 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2623

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11159


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm gmail.com


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2013-10-03
22:57:15 PDT ---
*** Issue 7548 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 03 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11159


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2013