diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-03-20 15:24:06 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-03-20 15:24:06 +0400 |
commit | 328edf8560dbf1941ce314fa112e0db05d9f97f1 (patch) | |
tree | d85a678df8f52caa4fce9e1347d5c60336721e09 /mysql-test/t/func_math.test | |
parent | 5c1ed707a3d03a081fde2b2c960998d797757adf (diff) | |
download | mariadb-git-328edf8560dbf1941ce314fa112e0db05d9f97f1.tar.gz |
MDEV-21977 main.func_math fails due to undefined behaviourbb-10.1-vicentiu-pristene
The problem happened in these line:
uval0= (ulonglong) (val0_negative ? -val0 : val0);
uval1= (ulonglong) (val1_negative ? -val1 : val1);
return check_integer_overflow(val0_negative ? -(longlong) res : res,
!val0_negative);
when unary minus was performed on -9223372036854775808.
This behavior is undefined in C/C++.
Diffstat (limited to 'mysql-test/t/func_math.test')
-rw-r--r-- | mysql-test/t/func_math.test | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index ebce8a8480c..89e9c4f4d49 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -693,5 +693,34 @@ DROP TABLE t1; --echo # +--echo # MDEV-21977 main.func_math fails due to undefined behaviour +--echo # + +SELECT 9223372036854775808 DIV 1; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775808 DIV -1; +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 DIV 1; +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 DIV -1; + +SELECT 9223372036854775808 MOD 1; +SELECT 9223372036854775808 MOD -1; +SELECT -9223372036854775808 MOD 1; +SELECT -9223372036854775808 MOD -1; + +SELECT 1 MOD 9223372036854775808; +SELECT -1 MOD 9223372036854775808; +SELECT 1 MOD -9223372036854775808; +SELECT -1 MOD -9223372036854775808; + +SELECT 9223372036854775808 MOD 9223372036854775808; +SELECT 9223372036854775808 MOD -9223372036854775808; +SELECT -9223372036854775808 MOD 9223372036854775808; +SELECT -9223372036854775808 MOD -9223372036854775808; + + + +--echo # --echo # End of 10.1 tests --echo # |