Skip to content

Commit

Permalink
Workaround broken __builtin_clz in clang with MS codegen (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jun 17, 2017
1 parent 24df4b2 commit 475e40d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 475e40d

Please sign in to comment.