Problems with floating point operations (not raising exceptions)
Original Reporter info from Mantis: zoran
-
Reporter name: Zoran Vučenović
Original Reporter info from Mantis: zoran
- Reporter name: Zoran Vučenović
Description:
It is reported in forum (topic: http://www.lazarus.freepascal.org/index.php/topic,13460.0.html) that compiler behaves differently on Linux and Windows when dividing.
It actually seems that lcl with gtk2 widgetset sets ExceptionMask variable to non-default value, which causes floating point exceptions not to be raised.
I believe that this floating point behavior should not depend on widgetset. The programmer should assume that if these exceptions are raised on one platform, they will be raised on another.
Additional information:
The uploaded zip file contains two very simple examples to illustrate this - a gui application and a command line one.
You can see that for inputs 5 and 0 command line application reports that EDivByZero was raised. For 0 and 0 EInvalidOp.
The GUI application, when compiled on Windows, reports the same. However, with gtk2 on Linux it gives +inf for 5 and 0, and NaN for 0 and 0. I haven't tested with Qt.
I believe that this behavior with floating point exceptions should not depend on widgetset. The default behavior should be same and known and the programmer should not be bothered with ExceptionMask unless (s)he wants non-default behavior.
Mantis conversion info:
- Mantis ID: 19674
- Version: 0.9.30.1 (SVN)