Thread overview
DMD Issue with Asm Generation?
Feb 13, 2016
user001
Feb 13, 2016
user001
Feb 14, 2016
jkpl
February 13, 2016
There seems to be some invalid code generation for std.format for type of "real". Relavant links:

https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1713
https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L5118


movabs rbx,7FF0000000000000                | <-- problem, should be 0x7FFF
and rax,rbx                                |
cmp rax,rbx                                |
jne test.7FF6FF4762E4                      |
mov rdx,qword ptr ss:[rbp-230]             |
movabs rcx,FFFFFFFFFFFFF                   |
test rdx,rcx                               |
je test.7FF6FF4762E4                       |
lea rax,qword ptr ds:[7FF6FF4C5C02]        | ;7FF6FF4C5C02:"nan"
mov qword ptr ss:[rbp-2C8],rax             |
mov qword ptr ss:[rbp-2D0],3               |
jmp test.7FF6FF476335                      |
mov rsi,qword ptr ss:[rbp-230]             |
movabs rax,7FFFFFFFFFFFFFFF                |
and rsi,rax                                |
cmp rsi,rbx                                |
jne test.7FF6FF476335                      |
fld tword ptr ss:[rbp-228]                 |
fldz                                       |
fcompi st1                                 |
fstp st0                                   |
ja test.7FF6FF47631B                       |
jp test.7FF6FF47631B                       |
lea rdx,qword ptr ds:[7FF6FF4C5C06]        | ;7FF6FF4C5C06:"inf"
mov ebx,3                                  |
jmp test.7FF6FF476327                      | ;format.d:1495
lea rdx,qword ptr ds:[7FF6FF4C5C0A]        | ;7FF6FF4C5C0A:"-inf"

Seems to compile fine with DMD at least with simpler code with just an if statement. Also this issue doesn't exist for 32-bit x86.
February 13, 2016
Disregard all that above, looks like someone used a "double" which uses 0x7FF0 to check if infinite. Not sure why the code runs fine on x86 though, different library maybe?

https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1709
February 14, 2016
On Saturday, 13 February 2016 at 20:50:22 UTC, user001 wrote:
> Disregard all that above, looks like someone used a "double" which uses 0x7FF0 to check if infinite. Not sure why the code runs fine on x86 though, different library maybe?
>
> https://github.com/D-Programming-Language/phobos/blob/master/std/format.d#L1709

yes the line you highlight is for DMD64 (windows of course), which explains well why x86 is OK since it uses the C runtime library by DigitalMars (aka snn.lib). Now I'm not quite sure if it should be

T tval = val;

because of the comment just after:

> convert early to get "inf" in case of overflow