[Issue 9844] DMD (-m64) int->long conversion bug
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 3 12:05:59 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9844
John Colvin <john.loughran.colvin at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |john.loughran.colvin at gmail.
| |com
--- Comment #3 from John Colvin <john.loughran.colvin at gmail.com> 2013-04-03 20:05:58 BST ---
A simplified test:
import std.stdio;
void foo() {
int a = -1;
long b = -1;
writeln(a); // -1
writeln(b); // (2^32)-1
}
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.
e.g.
mov eax,0xffffffff //rax is now 0x00000000ffffffff
mov DWORD PTR [rbp-0x10],eax
mov QWORD PTR [rbp-0x8],rax
I don't get any bug with ldc, so it's probably either a recent regression or a
backend problem.
--
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