Skip to content

Commit

Permalink
Fix undefined behavior in UDL macro
Browse files Browse the repository at this point in the history
`FMT_USE_USER_DEFINED_LITERALS` macro expands to `defined()` which is undefined behavior.
  • Loading branch information
bylee20 authored and vitaut committed Jul 13, 2017
1 parent 4045d7f commit 3028344
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3028344

Please sign in to comment.