[Issue 9844] DMD (-m64) int->long conversion bug

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 3 22:10:52 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9844



--- Comment #4 from safety0ff.bugz at gmail.com 2013-04-03 22:10:50 PDT ---
(In reply to comment #3)
> The mistake only happens when a and b are initialised to the same negative
> value.
> 
> In light of that and after some perusing of the asm generated, it appears that
> dmd goes "-1 == -1" and uses the same value for a as for b, except of course
> that doesn't work because of the different sign bit positions for int and long.

Yes, you're right, as demonstrated in this program:
import std.stdio;
void main() {
    int a = -2;
    long b = -1;
    long c = -2;
    writeln(a); // -2
    writeln(b); // -1
    writeln(c); // 2^32-2
}

I suppose I should now find a better title for this issue.

-- 
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