diff src/eval.c @ 10658:77d66e9ac0ab v8.0.0219

patch 8.0.0219: ubsan reports errors for overflow commit https://github.com/vim/vim/commit/7a40ea2138102545848ea86a361f1b8dec7552b5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 22 18:34:57 2017 +0100 patch 8.0.0219: ubsan reports errors for overflow Problem: Ubsan reports errors for integer overflow. Solution: Define macros for minimum and maximum values. Select an expression based on the value. (Mike Williams)
author Christian Brabandt <cb@256bit.org>
date Sun, 22 Jan 2017 18:45:04 +0100
parents 553f9b9502bc
children 8ba322dad776
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -4109,21 +4109,12 @@ eval6(
 		{
 		    if (n2 == 0)	/* give an error message? */
 		    {
-#ifdef FEAT_NUM64
 			if (n1 == 0)
-			    n1 = -0x7fffffffffffffffLL - 1; /* similar to NaN */
+			    n1 = VARNUM_MIN; /* similar to NaN */
 			else if (n1 < 0)
-			    n1 = -0x7fffffffffffffffLL;
+			    n1 = -VARNUM_MAX;
 			else
-			    n1 = 0x7fffffffffffffffLL;
-#else
-			if (n1 == 0)
-			    n1 = -0x7fffffffL - 1L;	/* similar to NaN */
-			else if (n1 < 0)
-			    n1 = -0x7fffffffL;
-			else
-			    n1 = 0x7fffffffL;
-#endif
+			    n1 = VARNUM_MAX;
 		    }
 		    else
 			n1 = n1 / n2;