From 569c5bdbf166e7227f2933ed83c7322263659bd9 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 17 Jun 2017 07:31:45 -0700 Subject: [PATCH] Workaround broken __builtin_clz in clang with MS codegen (#519) --- fmt/format.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index b56b8589..1db3d9da 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -287,12 +287,16 @@ typedef __int64 intmax_t; # define FMT_ASSERT(condition, message) assert((condition) && message) #endif -#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) -# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) -#endif +// __builtin_clz is broken in clang with Microsoft CodeGen: +// https://github.com/fmtlib/fmt/issues/519 +#ifndef _MSC_VER +# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) +# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) +# endif -#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll) -# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) +# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll) +# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) +# endif #endif // Some compilers masquerade as both MSVC and GCC-likes or