digitalmars.D.bugs - [Issue 16327] New: direct floating point equal comparison fails on
- via Digitalmars-d-bugs (79/79) Jul 27 2016 https://issues.dlang.org/show_bug.cgi?id=16327
https://issues.dlang.org/show_bug.cgi?id=16327 Issue ID: 16327 Summary: direct floating point equal comparison fails on 32-bit emulation Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: greensunny12 gmail.com -------- 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 --
Jul 27 2016