[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stdint causes warnings on Tru64
From: |
Bruno Haible |
Subject: |
stdint causes warnings on Tru64 |
Date: |
Mon, 29 Oct 2007 03:59:14 +0100 |
User-agent: |
KMail/1.5.4 |
Hi Paul,
The gnulib-substituted stdint.h causes a compiler warning from the
OSF/1 5.1 cc compiler, at every use of PTRDIFF_MAX or SIG_ATOMIC_MAX.
cc: Warning: test-stdint.c, line 260: In the declaration of
"verify_error_if_negative_size__", integer overflow occurs in evaluating the
expression "(((0)+1)<<((64)?(64)-1:0))-1". (intoverfl)
verify (TYPE_MAXIMUM (ptrdiff_t) == PTRDIFF_MAX);
^
cc: Warning: test-stdint.c, line 260: In the declaration of
"verify_error_if_negative_size__", integer overflow occurs in evaluating the
expression "((((0)+1)<<((64)?(64)-1:0))-1)*2". (intoverfl)
verify (TYPE_MAXIMUM (ptrdiff_t) == PTRDIFF_MAX);
^
cc: Warning: test-stdint.c, line 273: In the declaration of
"verify_error_if_negative_size__", integer overflow occurs in evaluating the
expression "(((0)+1)<<((32)?(32)-1:0))-1". (intoverfl)
verify (TYPE_MAXIMUM (sig_atomic_t) == SIG_ATOMIC_MAX);
^
cc: Warning: test-stdint.c, line 273: In the declaration of
"verify_error_if_negative_size__", integer overflow occurs in evaluating the
expression "((((0)+1)<<((32)?(32)-1:0))-1)*2". (intoverfl)
verify (TYPE_MAXIMUM (sig_atomic_t) == SIG_ATOMIC_MAX);
^
IMO warnings in .c files installed by gnulib are acceptable, but warnings
caused by .h files should be avoided. I'm applying this, since it fixes the
warning.
2007-10-28 Bruno Haible <address@hidden>
* 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.
--- lib/stdint.in.h.orig 2007-10-29 03:46:10.000000000 +0100
+++ lib/stdint.in.h 2007-10-29 03:34:10.000000000 +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 */
- stdint causes warnings on Tru64,
Bruno Haible <=