diff --git a/utils/funcexp/func_div.cpp b/utils/funcexp/func_div.cpp index 676b5a824..d75942b6d 100644 --- a/utils/funcexp/func_div.cpp +++ b/utils/funcexp/func_div.cpp @@ -24,6 +24,8 @@ #include #include #include +#define __STDC_LIMIT_MACROS +#include using namespace std; #include "functor_real.h" @@ -56,6 +58,12 @@ int64_t Func_div::getIntVal(rowgroup::Row& row, return 0; } int64_t int_val1 = (int64_t)(val1 > 0 ? val1 + 0.5 : val1 - 0.5); + // MCOL-176 If abs(int_val2) is small enough (like -1), then, this may cause overflow. + // This kludge stops the crash. + if (int_val1 == INT64_MIN) + { + --int_val1; + } return int_val1 / int_val2; }