diff options
Diffstat (limited to 'numpy/core/src/scalarmathmodule.c.src')
-rw-r--r-- | numpy/core/src/scalarmathmodule.c.src | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src index 6913f517d..c4e6263ba 100644 --- a/numpy/core/src/scalarmathmodule.c.src +++ b/numpy/core/src/scalarmathmodule.c.src @@ -651,7 +651,13 @@ static PyObject * { PyObject *ret; @name@ arg1, arg2; - @otyp@ out; + /* + * NOTE: In gcc >= 4.1, the compiler will reorder floating point operations and + * floating point error state checks. In particular, the arithmetic operations + * were being reordered so that the errors weren't caught. Declaring this output + * variable volatile was the minimal fix for the issue. (Ticket #1671) + */ + volatile @otyp@ out; #if @twoout@ @otyp@ out2; PyObject *obj; @@ -692,9 +698,9 @@ static PyObject * * as a function call. */ #if @twoout@ - @name@_ctype_@oper@(arg1, arg2, &out, &out2); + @name@_ctype_@oper@(arg1, arg2, (@otyp@ *)&out, &out2); #else - @name@_ctype_@oper@(arg1, arg2, &out); + @name@_ctype_@oper@(arg1, arg2, (@otyp@ *)&out); #endif #if @fperr@ |