avoid signed-integer overflow, which is undefined behavior
UBSAN gave for test/unittest/itoatest.cpp:87: runtime error: signed integer overflow: 4611686018427387904 * 2 cannot be represented in type 'long'
This commit is contained in:
parent
61637d3382
commit
be1eedf808
@ -84,6 +84,8 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {
|
|||||||
VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
|
VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
|
||||||
}
|
}
|
||||||
last = i;
|
last = i;
|
||||||
|
if (i > static_cast<T>(std::numeric_limits<T>::max() / static_cast<T>(power)))
|
||||||
|
break;
|
||||||
i *= power;
|
i *= power;
|
||||||
} while (last < i);
|
} while (last < i);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user