BUG: rolling with MSVC 2017 build by chris-b1 · Pull Request #21813 · pandas-dev/pandas (original) (raw)
I can reproduce it with this snippet (has a few tricks to try and defeat optimisations, but they are likely unnecessary):
#include <math.h> #include <stdio.h>
double get_value(int i) { return i > 1 ? NAN : 7; }
int check_default(double v1, double v2) { return ((v1 == v2) != 0); }
#pragma float_control(precise, off, push) int check_fast(double v1, double v2) { return ((v1 == v2) != 0); } #pragma float_control(pop)
int main(int argc, char **argv) { double x1 = get_value(argc); double x2 = get_value(argc); fprintf(stdout, "default: %d\nfast: %d\n", check_default(x1, x2), check_fast(x1, x2) ); }
The comparison doesn't behave properly when you disable precise floating point operations. You may be doing this in the build with /fp:fast (if you build this snippet with that option, both checks return '1'; if you build with the default /fp:precise, it works). In fact, the docs for this flag specifically call out NaN comparisons as something that only work in precise mode.
So I'd guess you need to update the compiler flags for this one, or possibly add an explicit isnan() call.