From 705764b377ebeef7bdba1a87fafd99cd56b6f3c9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 11 Apr 2016 08:42:02 -0700 Subject: [PATCH] stdint: port to strict C11 left shift * lib/stdint.in.h (_STDINT_MIN, _STDINT_MAX): Pacify clang -Wshift-negative-value, which should be an issue only on clang setups where stdint.h does not conform to C11 or to C++11. Problem reported by Philipp Stephani in: http://bugs.gnu.org/23261 --- ChangeLog | 8 ++++++++ lib/stdint.in.h | 9 ++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77f1be96cb..6c5913dabf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-04-11 Paul Eggert + + stdint: port to strict C11 left shift + * lib/stdint.in.h (_STDINT_MIN, _STDINT_MAX): + Pacify clang -Wshift-negative-value, which should be an issue only + on clang setups where stdint.h does not conform to C11 or to C++11. + Problem reported by Philipp Stephani in: http://bugs.gnu.org/23261 + 2016-04-09 Paul Eggert mbrtowc: work around glibc bug#19932 diff --git a/lib/stdint.in.h b/lib/stdint.in.h index f22e7d5259..51fee75d58 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -118,15 +118,10 @@ picky compilers. */ #define _STDINT_MIN(signed, bits, zero) \ - ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) + ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (zero)) #define _STDINT_MAX(signed, bits, zero) \ - ((signed) \ - ? ~ _STDINT_MIN (signed, bits, zero) \ - : /* 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) + (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) #if !GNULIB_defined_stdint_types -- 2.39.5