Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f06bee

Browse files
committed
Change PyFPE_END_PROTECT to PyFPE_END_PROTECT(v). v should be the
last variable to which a floating point expression is assigned. The macro passes its address to a dummy function so that the optimizer can't delay calculating its value until after the macro.
1 parent efd3a3a commit 1f06bee

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Include/pyfpe.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ extern "C" {
131131
#include <math.h>
132132
extern jmp_buf PyFPE_jbuf;
133133
extern int PyFPE_counter;
134-
extern double PyFPE_dummy(void);
134+
extern double PyFPE_dummy();
135135

136136
#define PyFPE_START_PROTECT(err_string, leave_stmt) \
137137
if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \
@@ -149,12 +149,12 @@ if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \
149149
* which counts down PyFPE_counter, and thereby monkey wrench the overeager
150150
* optimizer. Better solutions are welcomed....
151151
*/
152-
#define PyFPE_END_PROTECT PyFPE_counter -= (int)PyFPE_dummy();
152+
#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v));
153153

154154
#else
155155

156156
#define PyFPE_START_PROTECT(err_string, leave_stmt)
157-
#define PyFPE_END_PROTECT
157+
#define PyFPE_END_PROTECT(v)
158158

159159
#endif
160160

0 commit comments

Comments
 (0)