Tcl Source Code

Artifact [283ff28a9f]
Login

Artifact 283ff28a9f2504e474acac800aeba6271786b3e2:

Attachment "1770224.patch" to ticket [1770224fff] added by dgp 2007-08-09 03:21:04.
Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.309
diff -u -r1.309 tclExecute.c
--- generic/tclExecute.c	5 Aug 2007 02:46:09 -0000	1.309
+++ generic/tclExecute.c	8 Aug 2007 20:19:45 -0000
@@ -4506,10 +4506,14 @@
 	    invalid = (*((const Tcl_WideInt *)ptr2) < (Tcl_WideInt)0);
 	    break;
 #endif
-	case TCL_NUMBER_BIG:
-	    /* TODO: const correctness? */
-	    invalid = (mp_cmp_d((mp_int *)ptr2, 0) == MP_LT);
+	case TCL_NUMBER_BIG: {
+	    mp_int big2;
+
+	    Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
+	    invalid = (mp_cmp_d(&big2, 0) == MP_LT);
+	    mp_clear(&big2);
 	    break;
+	}
 	default:
 	    /* Unused, here to silence compiler warning */
 	    invalid = 0;
@@ -4617,10 +4621,13 @@
 		    zero = (*(const Tcl_WideInt *)ptr1 > (Tcl_WideInt)0);
 		    break;
 #endif
-		case TCL_NUMBER_BIG:
-		    /* TODO: const correctness ? */
-		    zero = (mp_cmp_d((mp_int *)ptr1, 0) == MP_GT);
+		case TCL_NUMBER_BIG: {
+		    mp_int big1;
+		    Tcl_TakeBignumFromObj(NULL, valuePtr, &big1);
+		    zero = (mp_cmp_d(&big1, 0) == MP_GT);
+		    mp_clear(&big1);
 		    break;
+		}
 		default:
 		    /* Unused, here to silence compiler warning. */
 		    zero = 0;
Index: tests/expr.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/expr.test,v
retrieving revision 1.67
diff -u -r1.67 expr.test
--- tests/expr.test	6 Dec 2006 16:37:00 -0000	1.67
+++ tests/expr.test	8 Aug 2007 20:19:49 -0000
@@ -6658,6 +6658,10 @@
     set trouble
 } {}
 
+test expr-48.1 {Bug 1770224} {
+    expr {-0x8000000000000001 >> 0x8000000000000000}
+} -1
+
 # cleanup
 if {[info exists a]} {
     unset a