Index: generic/tclGet.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclGet.c,v
retrieving revision 1.9
diff -u -r1.9 tclGet.c
--- generic/tclGet.c	6 Apr 2004 22:25:51 -0000	1.9
+++ generic/tclGet.c	19 Apr 2005 21:04:25 -0000
@@ -91,7 +91,11 @@
      * an int.
      */
 
-    if ((errno == ERANGE) || (((long)(int) i) != i)) {
+    if ((errno == ERANGE) 
+#if (LONG_MAX > INT_MAX)
+	    || (i > UINT_MAX) || (i < -(long)UINT_MAX)
+#endif
+    ) {
         if (interp != (Tcl_Interp *) NULL) {
 	    Tcl_SetResult(interp, "integer value too large to represent",
 		    TCL_STATIC);
Index: generic/tclObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclObj.c,v
retrieving revision 1.75
diff -u -r1.75 tclObj.c
--- generic/tclObj.c	5 Apr 2005 16:19:10 -0000	1.75
+++ generic/tclObj.c	19 Apr 2005 21:04:25 -0000
@@ -1958,15 +1958,14 @@
     register Tcl_Obj *objPtr;	/* The object from which to get a int. */
     register int *intPtr;	/* Place to store resulting int. */
 {
-    register long l = 0;
     int result;
+    Tcl_WideInt w = 0;
 
     /* If the object isn't already an integer of any width, try to
      * convert it to one.
      */
 
-    if (objPtr->typePtr != &tclIntType
-	    && objPtr->typePtr != &tclWideIntType) {
+    if (objPtr->typePtr != &tclIntType && objPtr->typePtr != &tclWideIntType) {
 	result = SetIntOrWideFromAny(interp, objPtr);
 	if (result != TCL_OK) {
 	    return result;
@@ -1975,45 +1974,26 @@
 
     /* Object should now be either int or wide. Get its value. */
 
-    if (objPtr->typePtr == &tclIntType) {
-	l = objPtr->internalRep.longValue;
-    } else if (objPtr->typePtr == &tclWideIntType) {
 #ifndef TCL_WIDE_INT_IS_LONG
-	/*
-	 * If the object is already a wide integer, don't convert it.
-	 * This code allows for any integer in the range -ULONG_MAX to
-	 * ULONG_MAX to be converted to a long, ignoring overflow.
-	 * The rule preserves existing semantics for conversion of
-	 * integers on input, but avoids inadvertent demotion of
-	 * wide integers to 32-bit ones in the internal rep.
-	 */
-	Tcl_WideInt w = objPtr->internalRep.wideValue;
-	if (w >= -(Tcl_WideInt)(ULONG_MAX)
-		&& w <= (Tcl_WideInt)(ULONG_MAX)) {
-	    l = Tcl_WideAsLong(w);
-	} else {
-	    goto tooBig;
-	}
-#else
-	l = objPtr->internalRep.longValue;
+    if (objPtr->typePtr == &tclWideIntType) {
+	w = objPtr->internalRep.wideValue;
+    } else
 #endif
-    } else {
-	Tcl_Panic("string->integer conversion failed to convert the obj.");
+    {
+	w = Tcl_LongAsWide(objPtr->internalRep.longValue);
     }
 
-    if (((long)((int)l)) == l) {
-	*intPtr = (int)l;
-	return TCL_OK;
-    }
-#ifndef TCL_WIDE_INT_IS_LONG
-  tooBig:
-#endif
-    if (interp != NULL) {
-	Tcl_SetObjResult(interp, Tcl_NewStringObj(
+    if ((LLONG_MAX > UINT_MAX)
+	    && ((w > UINT_MAX) || (w < -(Tcl_WideInt)UINT_MAX))) {
+	if (interp != NULL) {
+	    Tcl_SetObjResult(interp, Tcl_NewStringObj(
 		"integer value too large to represent as non-long integer",
 		-1));
+	}
+	return TCL_ERROR;
     }
-    return TCL_ERROR;
+    *intPtr = (int)w;
+    return TCL_OK;
 }
 
 /*
