From 30283443805745af3761be1682e6849766246e76 Mon Sep 17 00:00:00 2001 From: "Lee, Byoung-young" Date: Wed, 12 Jul 2017 11:01:58 +0900 Subject: [PATCH] Fix undefined behavior in UDL macro `FMT_USE_USER_DEFINED_LITERALS` macro expands to `defined()` which is undefined behavior. --- fmt/format.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index 4122495d..aeee2cc4 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -266,11 +266,14 @@ typedef __int64 intmax_t; // makes the fmt::literals implementation easier. However, an explicit check // for variadic templates is added here just in case. // For Intel's compiler both it and the system gcc/msc must support UDLs. -# define FMT_USE_USER_DEFINED_LITERALS \ - FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \ +# if FMT_USE_VARIADIC_TEMPLATES && FMT_USE_RVALUE_REFERENCES && \ (FMT_HAS_FEATURE(cxx_user_literals) || \ (FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900) && \ (!defined(FMT_ICC_VERSION) || FMT_ICC_VERSION >= 1500) +# define FMT_USE_USER_DEFINED_LITERALS 1 +# else +# define FMT_USE_USER_DEFINED_LITERALS 0 +# endif #endif #ifndef FMT_USE_EXTERN_TEMPLATES