From: Bruno Haible <bruno@clisp.org>
Date: Mon, 11 Jul 2005 11:29:40 +0000 (+0000)
Subject: Make it work also if size_t is smaller than unsigned int.
X-Git-Tag: cvs-readonly~3206
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c5ca5b38ca453581e7f78b5e8bd8b60599de1a34;p=gnulib.git

Make it work also if size_t is smaller than unsigned int.
---

diff --git a/m4/ChangeLog b/m4/ChangeLog
index 5e821d79bc..de300f00ae 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,9 @@
+2005-07-10  Bruno Haible  <bruno@clisp.org>
+
+	* size_max.m4 (gl_SIZE_MAX): Cast ~(size_t)0 back to size_t.
+	Needed when size_t is smaller than 'unsigned int'.
+	Reported by Paul Eggert.
+
 2005-07-07  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* backupfile.m4 (gl_BACKUPFILE): Use AC_CHECK_FUNCS_ONCE on pathconf.
diff --git a/m4/size_max.m4 b/m4/size_max.m4
index 4fe81c7b07..0336f3af50 100644
--- a/m4/size_max.m4
+++ b/m4/size_max.m4
@@ -1,5 +1,5 @@
-# size_max.m4 serial 2
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+# size_max.m4 serial 3
+dnl Copyright (C) 2003, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -26,9 +26,9 @@ Found it
     dnl than the type 'unsigned long'.
     dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
     dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
-    _AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
+    _AC_COMPUTE_INT([(size_t)~(size_t)0 / 10], res_hi,
       [#include <stddef.h>], result=?)
-    _AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
+    _AC_COMPUTE_INT([(size_t)~(size_t)0 % 10], res_lo,
       [#include <stddef.h>], result=?)
     _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
       [#include <stddef.h>], result=?)
@@ -48,7 +48,7 @@ Found it
       fi
     else
       dnl Shouldn't happen, but who knows...
-      result='~(size_t)0'
+      result='((size_t)~(size_t)0)'
     fi
   fi
   AC_MSG_RESULT([$result])