diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | generic/tclBasic.c | 12 | ||||
-rw-r--r-- | tests/expr.test | 6 |
3 files changed, 23 insertions, 7 deletions
@@ -1,10 +1,14 @@ 2005-08-05 Kevin Kenny <kennykb@users.sourceforge.net> - * win/makefile.vc: Removed unused file ldAout.tcl. - * win/makefile.bc: [Bug #1244361] + * win/makefile.vc: Removed unused file ldAout.tcl. + * win/makefile.bc: [Bug #1244361] - * tests/binary.test: Cleaned up testing for scanning of NaN. - [Bug #1246264] + * tests/binary.test: Cleaned up testing for scanning of NaN. + [Bug #1246264] + + * generic/tclBasic.c (ExprAbsFunc): Added code to handle the + * tests/expr.test (expr-38.1): corner case of applying + 'abs' to the smallest 32-bit integer. [Bug #1241572] 2005-08-04 Andreas Kupries <andreask@activestate.com> diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 5c36bbc..4414c52 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.164 2005/07/26 17:06:12 dgp Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.165 2005/08/05 18:50:27 kennykb Exp $ */ #include "tclInt.h" @@ -5091,12 +5091,20 @@ ExprAbsFunc(clientData, interp, objc, objv) if (i < 0) { iResult = -i; if (iResult < 0) { - /* FIXME: This should promote to wide! */ +#ifdef TCL_WIDE_INT_IS_LONG Tcl_SetObjResult(interp, Tcl_NewStringObj( "integer value too large to represent", -1)); Tcl_SetErrorCode(interp, "ARITH", "IOVERFLOW", "integer value too large to represent", (char *) NULL); return TCL_ERROR; +#else + /* + * Special case: abs(MIN_INT) must promote to wide. + */ + TclNewWideIntObj(oResult, -(Tcl_WideInt) i); + Tcl_SetObjResult(interp, oResult); + return TCL_OK; +#endif } } else { iResult = i; diff --git a/tests/expr.test b/tests/expr.test index 1aad141..89ac635 100644 --- a/tests/expr.test +++ b/tests/expr.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: expr.test,v 1.37 2005/07/28 18:42:28 dgp Exp $ +# RCS: @(#) $Id: expr.test,v 1.38 2005/08/05 18:50:30 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2.1 @@ -6453,6 +6453,10 @@ test expr-37.14 {expr edge cases} {wideIs64bit} { } {1 * -9223372036854775806 + -2 = -9223372036854775808} +test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} {wideIs64bit} { + expr {abs(-2147483648)} +} 2147483648 + # cleanup if {[info exists a]} { unset a |