Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.52
diff -u -r1.52 tclExecute.c
--- generic/tclExecute.c	15 Apr 2002 17:32:18 -0000	1.52
+++ generic/tclExecute.c	18 Apr 2002 12:54:33 -0000
@@ -4569,25 +4569,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 = TclGetString(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, TclGetString(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.13
diff -u -r1.13 expr-old.test
--- tests/expr-old.test	6 Dec 2001 10:59:17 -0000	1.13
+++ tests/expr-old.test	18 Apr 2002 12:54:34 -0000
@@ -934,6 +934,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."
