From 30c333214eab19dc2f196340ceeab0c74986a380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= Date: Wed, 11 Dec 2024 15:39:36 +0000 Subject: [PATCH] Patch Clang bug in __builtin_clzl by pushing volatile --- src/longlong.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/longlong.h b/src/longlong.h index 0ed4f24ae9..5003d85e58 100644 --- a/src/longlong.h +++ b/src/longlong.h @@ -25,6 +25,13 @@ extern "C" { #endif +/* FIXME: Bug in Clang 18 */ +#if __clang_major__ >= 18 +# define CLANG_volatile volatile +#else +# define CLANG_volatile +#endif + #if defined(__GNUC__) /* Trailing and leading zeros */ @@ -313,8 +320,8 @@ flint_bitcnt_t FLINT_BIT_COUNT(ulong x) # define udiv_qrnnd(q, r, n1, n0, d) \ do { \ - ulong __norm = flint_clz(d); \ - if (__norm) \ + CLANG_volatile int __norm = flint_clz(d); \ + if (__norm != 0) \ { \ udiv_qrnnd_int((q), (r), ((n1) << __norm) + ((n0) >> (FLINT_BITS - __norm)), (n0) << __norm, (d) << __norm); \ (r) = ((ulong) (r) >> __norm); \