From eee69256b669d580123dbc86d580da7c89fbdcf0 Mon Sep 17 00:00:00 2001 From: das Date: Thu, 15 Dec 2005 04:08:33 +0000 Subject: * generic/tclIOUtil.c: workaround gcc warning "comparison is always * generic/tclTest.c: false due to limited range of data type". --- ChangeLog | 3 +++ generic/tclIOUtil.c | 13 ++++++++++++- generic/tclTest.c | 13 ++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bfcda5..64e460a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-12-14 Daniel Steffen + * generic/tclIOUtil.c: workaround gcc warning "comparison is always + * generic/tclTest.c: false due to limited range of data type". + * macosx/Tcl.xcode/project.pbxproj: * macosx/Tcl.xcodeproj/project.pbxproj: * unix/Makefile.in: add new tclTomMath* files. diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 92203cc..c60cd8e 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.126 2005/11/27 02:33:49 das Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.127 2005/12/15 04:08:33 das Exp $ */ #include "tclInt.h" @@ -76,8 +76,19 @@ Tcl_Stat( # define OUT_OF_RANGE(x) \ (((Tcl_WideInt)(x)) < Tcl_LongAsWide(LONG_MIN) || \ ((Tcl_WideInt)(x)) > Tcl_LongAsWide(LONG_MAX)) +#if defined(__GNUC__) && __GNUC__ >= 2 +/* + * Workaround gcc warning of "comparison is always false due to limited range of + * data type" in this macro by checking max type size, and when necessary ANDing + * with the complement of ULONG_MAX instead of the comparison: + */ +# define OUT_OF_URANGE(x) \ + ((((Tcl_WideUInt)(~ (__typeof__(x)) 0)) > (Tcl_WideUInt)ULONG_MAX) && \ + (((Tcl_WideUInt)(x)) & ~(Tcl_WideUInt)ULONG_MAX)) +#else # define OUT_OF_URANGE(x) \ (((Tcl_WideUInt)(x)) > (Tcl_WideUInt)ULONG_MAX) +#endif /* * Perform the result-buffer overflow check manually. diff --git a/generic/tclTest.c b/generic/tclTest.c index dc5269c..db8d558 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTest.c,v 1.99 2005/11/04 22:38:38 msofer Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.100 2005/12/15 04:08:33 das Exp $ */ #define TCL_TEST @@ -5127,8 +5127,19 @@ static int PretendTclpStat(path, buf) # define OUT_OF_RANGE(x) \ (((Tcl_WideInt)(x)) < Tcl_LongAsWide(LONG_MIN) || \ ((Tcl_WideInt)(x)) > Tcl_LongAsWide(LONG_MAX)) +#if defined(__GNUC__) && __GNUC__ >= 2 +/* + * Workaround gcc warning of "comparison is always false due to limited range of + * data type" in this macro by checking max type size, and when necessary ANDing + * with the complement of ULONG_MAX instead of the comparison: + */ +# define OUT_OF_URANGE(x) \ + ((((Tcl_WideUInt)(~ (__typeof__(x)) 0)) > (Tcl_WideUInt)ULONG_MAX) && \ + (((Tcl_WideUInt)(x)) & ~(Tcl_WideUInt)ULONG_MAX)) +#else # define OUT_OF_URANGE(x) \ (((Tcl_WideUInt)(x)) > (Tcl_WideUInt)ULONG_MAX) +#endif /* * Perform the result-buffer overflow check manually. -- cgit v0.12