Forum > General

Multiple floating point traps when using external DLL

<< < (2/3) > >>

y.ivanov:
Thank you all for the suggestions.

At this point I've (only) changed the MSVC compiler floating point model option from /fp:precise to /fp:strict and that one muted the exceptions. Not sure the problem is solved - it is a lot of code and it needs exhaustive testing. I suspect I can hit the curbs at many other places, not only the fp. That fp issue just popped-up instantly.


--- Quote from: Thaddy on January 25, 2022, 06:07:57 pm ---*snip*
If you are not compiling for 32 bit i386 Windows, I need a small example.
If you are, I will post that example.

--- End quote ---
Oops, sorry for not giving more details about.
It is a 32 bit application.
The MSVC compiler is rather old: Microsoft Visual C++ 2008.
Lazarus 1.9.0 r63034 FPC 3.1.1 i386-win32-win32/win64.
The original application was built using C++Builder 5.0 Build 12.34. C++Builder capacity was outgrown long time ago.
Now I desperately need a new means of handling the GUI and I'm putting the non-gui part into a DLL.

What about compiling the DLL with TDM-GCC32 for example? Will it be better?

PascalDragon:

--- Quote from: Thaddy on January 26, 2022, 02:54:29 pm ---That is correct, in so far that afaik there is an option to enable 8087() in x86_32-win64.
That sounds funny, is hidden, but Florian did that. I forgot the option. Intel/AMD only.

--- End quote ---

We do not advertise that option by default and do not suggest to use it.

Also even then the problem would still be there, because Set8087CW still only sets the control word of the x87 and if the C code uses SSE instead of x87 (which MSVC generated code for x64 always does) then there'd still be exceptions, because SetSSECW wasn't used. So, in short, always use SetExceptionMask and at best forget about Set8087CW except if you have very specific use cases (changing rounding mode has specific functions that handles both x87 and SSE at once as well).

Thaddy:
Well, SetExceptionMask is the way to go then. Glad that I forgot that option I mentioned  ;D

There's a good chance that this example from the wiki is sufficient:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Math;//...begin  SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);

y.ivanov:

--- Quote from: Thaddy on January 27, 2022, 10:04:35 am ---Well, SetExceptionMask is the way to go then. Glad that I forgot that option I mentioned  ;D

There's a good chance that this example from the wiki is sufficient:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses Math;//...begin  SetExceptionMask(GetExceptionMask + [exOverflow,exZeroDivide,exInvalidOp]);
--- End quote ---

Follow-up:
Using SetExceptionMask also worked by muting the exceptions. I'll use both ways together with the MSVC option /fp:strict to be more certain

 
--- Quote from: y.ivanov on January 27, 2022, 09:41:40 am ---*snip*
What about compiling the DLL with TDM-GCC32 for example? Will it be better?

--- End quote ---
Does anybody have opinion on that?

Thaddy:

--- Quote from: y.ivanov on January 27, 2022, 02:13:04 pm ---Does anybody have opinion on that?

--- End quote ---
Well, Both GNU compilers and the Borland/Embarcadero compilers adhere to the IEEE standards for floating point handling and MSVC does not...
So yes, that may be worth a try to build with a different compiler..

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version