While shifting "value" to left, we would iterate through all bits
of an unsigned long long, while we only expect to count through
"size * CHAR_BIT" bits.

This fixes fate with MSVC.
---
 compat/stdbit/stdbit.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compat/stdbit/stdbit.h b/compat/stdbit/stdbit.h
index b434fc2357..3197a24938 100644
--- a/compat/stdbit/stdbit.h
+++ b/compat/stdbit/stdbit.h
@@ -179,9 +179,10 @@ static inline unsigned int __stdc_trailing_zeros(unsigned 
long long value,
                                                  unsigned int size)
 {
     unsigned int zeros = size * CHAR_BIT;
+    unsigned long long mask = (1ULL << (size * CHAR_BIT)) - 1;
 
     while (value != 0) {
-        value <<= 1;
+        value = (value << 1) & mask;
         zeros--;
     }
 
-- 
2.39.5 (Apple Git-154)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to