diff options
-rw-r--r-- | CHANGES.current | 4 | ||||
-rw-r--r-- | Lib/typemaps/primtypes.swg | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/CHANGES.current b/CHANGES.current index 5caaddbe7..588459210 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.2.0 (in progress) =========================== +2023-04-21: degasus + #2519 Fix CanCastAsInteger range check to clear errno first to fix + bogus failures for valid inputs.if errno is set. + 2023-04-21: ZackerySpytz [OCaml] #1439 Fix reference typemaps for std::string diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index dd80eb775..85a0b8d9b 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -252,9 +252,11 @@ SWIGINTERNINLINE int SWIG_CanCastAsInteger(double *d, double min, double max) { double x = *d; if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + double fx, cx, rd; + errno = 0; + fx = floor(x); + cx = ceil(x); + rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ if ((errno == EDOM) || (errno == ERANGE)) { errno = 0; } else { |