Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

direct floating point equal comparison fails on 32-bit emulation #19164

Open
dlangBugzillaToGithub opened this issue Jul 27, 2016 · 0 comments
Open
Labels

Comments

@dlangBugzillaToGithub
Copy link

Seb reported this on 2016-07-27T17:05:54Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=16327

Description

--------
S fun(S)(in S x)
{
    return -1 / x;
}

unittest
{
    import std.meta : AliasSeq;
    foreach (S; AliasSeq!(float, double, real))
    {
        import std.stdio;
        S i = fun!S(3);
        assert(i == S(-1) / 3); // this lines passes
        assert(fun!S(3) == S(-1) / 3); // error
    }
}
--------

I tested 32-bit with this command on a x86_64 platform.

rdmd -main -unittest -m32

Assembler:
----------

.text._D3foo14__unittestL6_1FZv segment
        assume  CS:.text._D3foo14__unittestL6_1FZv
_D3foo14__unittestL6_1FZv:
                push    EBP
                mov     EBP,ESP
                sub     ESP,4
                push    dword ptr FLAT:.rodata[08h]
                call      _D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf@PC32
                fstp    float ptr -4[EBP]
                fld     float ptr -4[EBP]
                fld     float ptr _D3foo12__ModuleInfoZ@SYM32[0Dh]
                fucompp ST(1),ST
                fstsw   AX
                sahf
                jp      L26
                je      L30
L26:            mov     EAX,0Eh
                call      _D3foo15__unittest_failFiZv@PC32
L30:            push    dword ptr _TMP3@SYM32[0Ah]
                call      _D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf@PC32
                fld     float ptr _TMP3@SYM32[019h]
                fucompp ST(1),ST
                fstsw   AX
                sahf
                jp      L4A
                je      L54
L4A:            mov     EAX,0Fh
                call      _D3foo15__unittest_failFiZv@PC32
L54:            leave
                ret
                nop
                nop
.text._D3foo14__unittestL6_1FZv ends
.text._D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf     segment
        assume  CS:.text._D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf
_D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf:
                fld     float ptr FLAT:.rodata[0Ah]
                fdiv    float ptr 4[ESP]
                ret     4
                nop
                nop
                nop
.text._D3foo15__T8crazyfunTfZ8crazyfunFNaNbNiNfxfZf     ends
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant