changeset 29113:c6e4859ca538

Fix "integer overflow" warnings with OSF/1 5.1 cc.
author Bruno Haible <bruno@clisp.org>
date Mon, 29 Oct 2007 03:59:04 +0100
parents 326902134568
children d57f7b5c5048
files ChangeLog lib/stdint.in.h
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 29 03:56:55 2007 +0100
+++ b/ChangeLog	Mon Oct 29 03:59:04 2007 +0100
@@ -1,3 +1,8 @@
+2007-10-28  Bruno Haible  <bruno@clisp.org>
+
+	* lib/stdint.in.h (_STDINT_MAX): Subtract 1 from an unused signed
+	integer shift in the signed case. Fixes warnings with OSF/1 5.1 cc.
+
 2007-10-28  Bruno Haible  <bruno@clisp.org>
 
 	Fix link errors with Sun C 5.0 on Solaris 10.
--- a/lib/stdint.in.h	Mon Oct 29 03:56:55 2007 +0100
+++ b/lib/stdint.in.h	Mon Oct 29 03:59:04 2007 +0100
@@ -101,7 +101,10 @@
 #define _STDINT_MAX(signed, bits, zero) \
   ((signed) \
    ? ~ _STDINT_MIN (signed, bits, zero) \
-   : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1)
+   : /* The expression for the unsigned case.  The subtraction of (signed) \
+	is a nop in the unsigned case and avoids "signed integer overflow" \
+	warnings in the signed case.  */ \
+     ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
 
 /* 7.18.1.1. Exact-width integer types */