certain divisions in single precision only
Original Reporter info from Mantis: tomaschel
-
Reporter name: Tomas Ledvinka
Original Reporter info from Mantis: tomaschel
- Reporter name: Tomas Ledvinka
Description:
Dear fpc developers,
Let me submit a divison bug:
When a floating point constant which can be represented exactly in single precision is divided by integer variable, the result is assumed to be a single-precision number.
program div5;
var five:integer=5;
begin
writeln(1.0/five);
writeln(1.0/five-1/five);
end.
--- OUTPUT ---
2.000000030E-01
2.9802322276673010E-009
--------------------
versions where problem spotted:
3.0.4 [2019/10/27] for x86_64 on windows
3.0.4+dfsg-18ubuntu2 [2018/08/29] for x86_64
older version with no problem:
fpc 2.6.4 i386-win32 is OK
Thanks
Steps to reproduce:
see the program above
Additional information:
disassembly shows use of single precision arithmetics
movswl TC_P
HELLOWORLD_$$_FIVE,%eax ; five is 16-bit integer type
cvtsi2ss %eax,%xmm0 ;
movss _HELLOWORLD
_Ld1,%xmm1 ; OK, constant 1.0 fits into single precision exactly
divss %xmm0,%xmm1 ; NOT OK (only single precision arithmetics used)
movss %xmm1,-20(%rbp) ; NOT OK
Mantis conversion info:
- Mantis ID: 36415
- Version: 3.0.4
- Monitored by: » @martok (Martok), » Cyrax (Cyrax)