Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.10.2.2
diff -u -r1.10.2.2 tclExecute.c
--- generic/tclExecute.c	7 Aug 2001 15:41:20 -0000	1.10.2.2
+++ generic/tclExecute.c	18 Apr 2002 12:37:41 -0000
@@ -3138,25 +3138,33 @@
 		operatorStrings[opCode - INST_LOR], "\"", (char *) NULL);
     } else {
 	char *msg = "non-numeric string";
-	if (opndPtr->typePtr != &tclDoubleType) {
+	char *s;
+	int length;
+
+	s = Tcl_GetStringFromObj(opndPtr, &length);
+	if (TclLooksLikeInt(s, length)) {
+	    /*
+	     * If something that looks like an integer appears here, then 
+	     * it *must* be a bad octal or too large to represent [Bug  542588].
+	     */
+
+	    if (TclCheckBadOctal(NULL, Tcl_GetString(opndPtr))) {
+		msg = "invalid octal number";
+	    } else {
+		msg = "integer value too large to represent";
+		Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW",
+		    "integer value too large to represent", (char *) NULL);
+	    }
+	} else {
 	    /*
 	     * See if the operand can be interpreted as a double in order to
 	     * improve the error message.
 	     */
 
-	    char *s = Tcl_GetString(opndPtr);
 	    double d;
 
 	    if (Tcl_GetDouble((Tcl_Interp *) NULL, s, &d) == TCL_OK) {
-		/*
-		 * Make sure that what appears to be a double
-		 * (ie 08) isn't really a bad octal
-		 */
-		if (TclCheckBadOctal(NULL, Tcl_GetString(opndPtr))) {
-		    msg = "invalid octal number";
-		} else {
-		    msg = "floating-point value";
-		}
+		msg = "floating-point value";
 	    }
 	}
 	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "can't use ",
Index: tests/expr-old.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/expr-old.test,v
retrieving revision 1.8
diff -u -r1.8 expr-old.test
--- tests/expr-old.test	10 Apr 2000 17:18:58 -0000	1.8
+++ tests/expr-old.test	18 Apr 2002 12:37:42 -0000
@@ -904,6 +904,13 @@
     list [catch {expr 78e} msg] $msg
 } {1 {syntax error in expression "78e"}}
 
+# test for [Bug #542588]
+test expr-old-36.11 {ExprLooksLikeInt procedure} {
+    # define a "too large integer"; this one works also for 64bit arith
+    set x 665802003400000000000000
+    list [catch {expr {$x+1}} msg] $msg
+} {1 {can't use integer value too large to represent as operand of "+"}}
+
 if {[info commands testexprlong] == {}} {
     puts "This application hasn't been compiled with the \"testexprlong\""
     puts "command, so I can't test Tcl_ExprLong etc."
