summaryrefslogtreecommitdiff
path: root/sql/item_func.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2013-03-12 20:09:49 +0100
committerVladislav Vaintroub <wlad@montyprogram.com>2013-03-12 20:09:49 +0100
commit2ede76c1d7144ab6a2881055f2bce0355ad40048 (patch)
treed3807857789b228e14e6127cb788d340faaddde1 /sql/item_func.cc
parent806e6cda27cb4b333725d797a04ae8199fe97244 (diff)
downloadmariadb-git-2ede76c1d7144ab6a2881055f2bce0355ad40048.tar.gz
MDEV-4224 : func_math test fails, when clang 3.0 compiler is used.
The reason for the problem was negation of signed longlong value LONGLON G_MIN in Item_func_neg::int_op() - the result of this operation is not defined (in C/C++ standard). With this patch, LONGLONG_MIN is handled as special value, and negation is avoided.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r--sql/item_func.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 6cfb3a9608d..0124ae3f1c8 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1907,6 +1907,14 @@ longlong Item_func_neg::int_op()
if (args[0]->unsigned_flag &&
(ulonglong) value > (ulonglong) LONGLONG_MAX + 1)
return raise_integer_overflow();
+
+ if (value == LONGLONG_MIN)
+ if (args[0]->unsigned_flag != unsigned_flag)
+ /* negation of LONGLONG_MIN is LONGLONG_MIN. */
+ return LONGLONG_MIN;
+ else
+ return raise_integer_overflow();
+
return check_integer_overflow(-value, !args[0]->unsigned_flag && value < 0);
}