Project

General

Profile

Actions

Bug #4105

closed

Bug in numeric.c for Borland compiler

Added by wvdbos (W van den Bos) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]
Backport:
[ruby-core:33503]

Description

=begin
There is a potential bug in Init_Numeric()

#elif defined(BORLANDC)
/* Turn off floating point exceptions for overflow, etc. */
_control87(MCW_EM, MCW_EM);
#endif

This call wil set the coprocessor in a state that double floating point will become single float when an exception is thrown

See http://qc.embarcadero.com/wc/qcmain.aspx?d=32483 for the workaround.

The next code should eleminate this

#elif defined(BORLANDC)
/* Turn off floating point exceptions for overflow, etc. */
_control87(MCW_EM, MCW_EM);
_control87(_control87(0,0),0x1FFF);
#endif

This will only appear when borland and for example microsoft dll's are mixed.
This can happend when OpenGl dll's are used

Btw. This source is also present in 1.8

I found this problem because I created a borland dll calling the ruby mswin32 version dll
It generated strange errors. A 'puts 0.0' generated a devide by zero in the ruby sprintf implementation
Putting the two _control87 calls in my dll solved this.
I found the same construction in the Ruby source without the second _control87 call :-)
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0