Commit 4218a2f3 authored by Alexander A. Maly's avatar Alexander A. Maly

More robust overflow detection for iabs((-2)**31)

(y == 0 && y + y == 0) didn't work for MSVS 2015
parent 675c6a2d
Pipeline #1296 passed with stages
in 3 minutes and 5 seconds
......@@ -355,7 +355,7 @@ public:
static int iabs(int x)
{
unsigned int y = (unsigned int) x;
if (y != 0 && y + y == 0) {
if (y == 0x80000000U) {
Core::abort(L"Целочисленное переполнение");
return 0;
}
......
......@@ -1361,6 +1361,7 @@ void KumirVM::do_stdcall(uint16_t alg)
int x = valuesStack_.pop().toInt();
int y = Kumir::Math::iabs(x);
valuesStack_.push(Variable(y));
error_ = Kumir::Core::getError();
break;
}
/* алг цел imax(цел x, цел y) */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment