emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115117: * data.c: Work around bogus GCC diagnostic


From: Paul Eggert
Subject: [Emacs-diffs] trunk r115117: * data.c: Work around bogus GCC diagnostic about shift count.
Date: Fri, 15 Nov 2013 18:01:08 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115117
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2013-11-15 10:01:04 -0800
message:
  * data.c: Work around bogus GCC diagnostic about shift count.
  
  Reported by Eli Zaretskii in
  <http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00489.html>.
  (pre_value): New function.
  (count_trailing_zero_bits): Use it.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/data.c                     data.c-20091113204419-o5vbwnq5f7feedwu-251
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-11-15 08:18:37 +0000
+++ b/src/ChangeLog     2013-11-15 18:01:04 +0000
@@ -1,3 +1,11 @@
+2013-11-15  Paul Eggert  <address@hidden>
+
+       * data.c: Work around bogus GCC diagnostic about shift count.
+       Reported by Eli Zaretskii in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-11/msg00489.html>.
+       (pre_value): New function.
+       (count_trailing_zero_bits): Use it.
+
 2013-11-15  Eli Zaretskii  <address@hidden>
 
        * lisp.h (DEBUGGER_SEES_C_MACROS) [GCC < v3.5]: Pessimistically

=== modified file 'src/data.c'
--- a/src/data.c        2013-11-14 02:39:28 +0000
+++ b/src/data.c        2013-11-15 18:01:04 +0000
@@ -3078,6 +3078,16 @@
   return changed ? dest : Qnil;
 }
 
+/* PRECONDITION must be true.  Return VALUE.  This odd construction
+   works around a bogus GCC diagnostic "shift count >= width of type".  */
+
+static int
+pre_value (bool precondition, int value)
+{
+  eassume (precondition);
+  return precondition ? value : 0;
+}
+
 /* Compute the number of trailing zero bits in val.  If val is zero,
    return the number of bits in val.  */
 static int
@@ -3111,7 +3121,8 @@
 
       if (BITS_PER_BITS_WORD % BITS_PER_ULL != 0
          && BITS_WORD_MAX == (bits_word) -1)
-       val |= (bits_word) 1 << (BITS_PER_BITS_WORD % BITS_PER_ULL);
+       val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
+                                          BITS_PER_BITS_WORD % BITS_PER_ULL);
       return count + count_trailing_zeros_ll (val);
     }
 }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]