8000 BUG: Work-around clang failure to set warning flags in fmod · numpy/numpy@5d3e85d · GitHub
[go: up one dir, main page]

Skip to content

Commit 5d3e85d

Browse files
committed
BUG: Work-around clang failure to set warning flags in fmod
1 parent 20ccdce commit 5d3e85d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

numpy/core/src/npymath/npy_math_internal.h.src

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,15 @@ npy_remainder@c@(@type@ a, @type@ b)
636636
npy_divmod@c@(a, b, &mod);
637637
return mod;
638638
}
639-
else {
640-
/*
641-
* in2 == 0 (and not NaN), normal division will give the correct
642-
* result (which could be Inf or NaN) and set the correct CPU
643-
* floating point error flag.
644-
*/
645-
return npy_fmod@c@(a, b);
646-
}
639+
/*
640+
* in2 == 0 (and not NaN). The result is always NaN here, and we need to
641+
* set the invalid flag if a is not NaN. We should be able to use the
642+
* normal fmod, but clang seems to optimize the warning flags away.
643+
*/
644+
if (!npy_isnan(a)) {
645+
npy_set_floatstatus_invalid();
646+
}
647+
return (@type@)NPY_NAN;
647648
}
648649

649650
NPY_INPLACE @type@

0 commit comments

Comments
 (0)
0