We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d15fdee commit 7a92e1bCopy full SHA for 7a92e1b
src/types.cpp
@@ -615,7 +615,8 @@ Rational floatToRationalCast(float f) {
615
// below. (INT_MAX can be represented accurately as a double, but
616
// gets rounded when it's converted to float.)
617
const double d = f;
618
- const bool in_range = std::numeric_limits<int32_t>::min() <= d && d <= std::numeric_limits<int32_t>::max();
+ // Don't allow INT_MIN (0x80000000) because it can cause a UBSAN failure in std::gcd().
619
+ const bool in_range = std::numeric_limits<int32_t>::min() < d && d <= std::numeric_limits<int32_t>::max();
620
if (!in_range) {
621
return {d > 0 ? 1 : -1, 0};
622
}
0 commit comments