[fpc-pascal] FPU Configuration inside a library
Michael Van Canneyt
michael at freepascal.org
Tue Sep 25 14:05:45 CEST 2007
On Tue, 25 Sep 2007, Adrian Veith wrote:
> i posted this already under a differnt subject, but didn't get a feedback.
> A .dll written in fpc changes the configuration of the FPU (FPUCW). This might
> cause a strange behavior inside the loading program.
> If the loading program allows division by zero (1.0 / 0.0), it will crash
> after the .dll written in freepascal is loaded. What is really bad with this
> is, that the crash occurs at total different place and time inside the loading
> program (very hard to find).
> The initialization of fpc should only change the FPU configuration inside a
> program not inside a library.
This is not so easy. The compiler has no way of knowing what code will be
executed in the initialization sections of the units inside the library.
The ABI also makes no demand. I've seen much Delphi code which
explictly saves and restores the FPU control word around a call to
> IMHO same should be true with other settings like LOCALE settings.
FPC does not change the locale settings. If the user does not change
it, then neither does the library.
More information about the fpc-pascal