New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Py_IS_INFINITY defect causes test_cmath failure on x86 #48825
Comments
In bpo-4506, Skip reported that test_cmath fails on Solaris 10/x86 for Problem: Py_IS_INFINITY is applied to a floating-point value sitting in an Solution: Add a macro to pymath.h that forces rounding from extended Problem: After applying the attached patch to the py3k branch, the cmath running build_ext Solution: ??? Christian, as the architect of pymath.h, do you have any ideas what I'm |
Here's a patch (force_to_memory2.patch) that I'm hoping fixes the cmath Skip, could you give it a try? The patch isn't final: I need to look for more places where By the way, it looks like the problem with the original patch, on OS X, |
may be proposed patch break platforms that need specific "export" decoration |
Mark> Skip, could you give it a try? Works for me on Solaris 10/x86. Based on Roumen's comment I am preparing to Skip |
I'm not sure that patch has to deal with "force to memory". My note about issue follow:
- pyport.h
#ifdef __MINGW32__
...
/*NOTE: mingw has isinf as macro defined in math.h.
Since PC/pyconfig.h define Py_IS_INFINITY(X) that cover HAVE_ISINF
here for Py_IS_INFINITY we define same as for native build.
This makes HAVE_ISINF needless.
Also see comments in configure.in and pymath.h. */
#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
....
next lest see Py_IS_INFINITY in pymath.h
....
#ifndef Py_IS_INFINITY
#ifdef HAVE_ISINF
#define Py_IS_INFINITY(X) isinf(X)
#else
#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
#endif
#endif
.... Is the macro Py_IS_INFINITY correct if isinf is not detected by Also I think too that problem is that we has to classify result after |
As Skip Montanaro report that work on ... may be macro from pymath.h has |
about "export" decoration it is find in then patch PyAPI_FUNC(double) . |
The macro Py_IS_INFINITY don't work on linux. The test case(force-inf.c) isinf(x)=1 |
Thanks, Roumen. I rather suspected that Py_IS_INFINITY was dodgy this On the other hand, this is only a problem when Py_IS_INFINITY is applied |
Took me awhile to locate a SPARC C compiler on our dwindling set of Skip |
Thanks, Skip. Looks like this problem is 'solved in principle'. Now I |
Final patch. Skip, could you please give this one a try, and then with any luck this I've added a configure test that detects x87 FPU usage, via the double When you configure on a machine that uses x87, you should see: checking for x87-style double rounding... yes in the configure output. |
Looking at this again, I don't like my solution. I think it would be better to fix Py_IS_INFINITY directly, putting all the The fixed Py_IS_INFINITY will likely be slower, but this only matters on |
Tim, I'm in need of some advice on Py_IS_INFINITY. It's currently #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) I'd like to rewrite it as something like: #define Py_IS_INFINITY_D(X) ((X) < -DBL_MAX || (X) > DBL_MAX)
#define Py_IS_INFINITY_F(X) ((X) < -FLT_MAX || (X) > FLT_MAX)
#define Py_IS_INFINITY(X) (sizeof(X) == sizeof(double) ? Py_IS_INFINITY_D(X) : Py_IS_INFINITY_F(X)) Are there any hidden (or obvious) numerical pitfalls with The reason for the rewrite is that the current Py_IS_INFINITY |
s/false positives/false negatives/ |
Answering my own question, there *are* pitfalls: (X) > DBL_LONG_MAX will Another not-so-bright idea down the drain... |
Fixed (I hope!) in the trunk in r69459. I'll wait for buildbot results The same test_cmath failure can also be seen on OS X 10.5.6/Intel when |
Merged to py3k in r69465. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: