* lib/count-leading-zeros.h (COUNT_LEADING_ZEROS):
* lib/count-trailing-zeros.h (COUNT_TRAILING_ZEROS):
Go back to putting the decls outside the for-loop,
as the identifiers are used after the loop is over.
---
 ChangeLog                  | 6 ++++++
 lib/count-leading-zeros.h  | 5 +++--
 lib/count-trailing-zeros.h | 3 ++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1cfaf9e528..a5de9bc51a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2025-11-23  Paul Eggert  <[email protected]>
 
+       count-leading-zeros: fix 2025-11-18 regression
+       * lib/count-leading-zeros.h (COUNT_LEADING_ZEROS):
+       * lib/count-trailing-zeros.h (COUNT_TRAILING_ZEROS):
+       Go back to putting the decls outside the for-loop,
+       as the identifiers are used after the loop is over.
+
        Port to C23 qualifier-generic fns like strchr
        This ports Gnulib to strict C23 platforms that reject code
        like ‘char *q = strchr (P, 'x');’ when P is a pointer to const,
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index a737e92d96..c79c0cb966 100644
--- a/lib/count-leading-zeros.h
+++ b/lib/count-leading-zeros.h
@@ -64,10 +64,11 @@ extern unsigned char _BitScanReverse64 (unsigned long *, 
unsigned long long);
 # define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE)                \
     do                                                                  \
       {                                                                 \
-        unsigned int leading_32;                                        \
         if (! x)                                                        \
           return CHAR_BIT * sizeof x;                                   \
-        for (int count = 0;                                             \
+        int count;                                                      \
+        unsigned int leading_32;                                        \
+        for (count = 0;                                                 \
              (leading_32 = ((x >> (sizeof (TYPE) * CHAR_BIT - 32))      \
                             & 0xffffffffU),                             \
               count < CHAR_BIT * sizeof x - 32 && !leading_32);         \
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index bc2001255b..58048cd093 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -64,7 +64,8 @@ extern unsigned char _BitScanForward64 (unsigned long *, 
unsigned long long);
       {                                                                 \
         if (! x)                                                        \
           return CHAR_BIT * sizeof x;                                   \
-        for (int count = 0;                                             \
+        int count;                                                      \
+        for (count = 0;                                                 \
              (count < CHAR_BIT * sizeof x - 32                          \
               && ! (x & 0xffffffffU));                                  \
              count += 32)                                               \
-- 
2.51.0


Reply via email to