ClearExceptions catches only first few floating point exceptions
Original Reporter info from Mantis: Michalis @michaliskambi
-
Reporter name: Michalis Kamburelis
Original Reporter info from Mantis: Michalis @michaliskambi
- Reporter name: Michalis Kamburelis
Description:
Attached program intentionally does an invalid floating-point operation (sqrt from negative value). This should produce exception "EInvalidOp : Invalid floating point operation". Although floating-point exceptions are not guaranteed to happen immediately, I use "ClearExceptions(true)" and then place the whole thing within try..except block that silences the exception. And it works, but only the first few times.
For "Sqrt" from negative value, it works for the first 7 executions (yes, always seven, it's 100% reproducible on my system).
For "Ln" from negative value, it works for the first 4 executions.
If you repeat this, say, 20 times, you see that EInvalidOp somehow "leaked out" from try..except block, or maybe ClearExceptions didn't clear it properly, and EInvalidOp is raised on other, unrelated and innocent floating point operations. Running attached program:
$ fpc -Mobjfpc -gl test_raise.pas
$ ./test_raise
silenced exception
silenced exception
silenced exception
silenced exception
silenced exception
silenced exception
silenced exception
An unhandled exception occurred at $080480E2 :
EInvalidOp : Invalid floating point operation
$080480E2 main, line 40 of test_raise.pas
while the correct result would be 20 lines of "silenced exception". FPC 2.2.0 works Ok here, FPC 2.2.2 is broken for this.
Mantis conversion info:
- Mantis ID: 12214
- OS: Debian GNU/Linux
- OS Build: (testing)
- Platform: i386
- Version: 2.2.2
- Fixed in version: 2.2.4
- Fixed in revision: 11822 (#6ed56036)
- Monitored by: » crossbuilder (Burkhard Carstens)