Index: generic/tclObj.c ================================================================== --- generic/tclObj.c +++ generic/tclObj.c @@ -3087,16 +3087,20 @@ if (mp_to_unsigned_bin_n(&big, bytes, &numBytes) == MP_OKAY) { while (numBytes-- > 0) { value = (value << CHAR_BIT) | *bytes++; } - if (big.sign) { - *wideIntPtr = - (Tcl_WideInt) value; + if ( (!big.sign) && ((Tcl_WideInt)value < 0) ) { + /* signed overflow - fall through to produce an error */ } else { - *wideIntPtr = (Tcl_WideInt) value; + if (big.sign) { + *wideIntPtr = - (Tcl_WideInt) value; + } else { + *wideIntPtr = (Tcl_WideInt) value; + } + return TCL_OK; } - return TCL_OK; } } if (interp != NULL) { const char *s = "integer value too large to represent"; Tcl_Obj* msg = Tcl_NewStringObj(s, -1);