diff --git a/include/fmt/core.h b/include/fmt/core.h index b5c5f252..a9116314 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -284,7 +284,8 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line, #ifndef FMT_ASSERT # ifdef NDEBUG -# define FMT_ASSERT(condition, message) + // FMT_ASSERT is not empty to avoid -Werror=empty-body. +# define FMT_ASSERT(condition, message) ((void)0) # else # define FMT_ASSERT(condition, message) \ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ @@ -316,18 +317,6 @@ struct int128_t {}; struct uint128_t {}; #endif -#ifndef FMT_USE_FLOAT -# define FMT_USE_FLOAT 1 -#endif - -#ifndef FMT_USE_DOUBLE -# define FMT_USE_DOUBLE 1 -#endif - -#ifndef FMT_USE_LONG_DOUBLE -# define FMT_USE_LONG_DOUBLE 1 -#endif - // Casts a nonnegative integer to unsigned. template FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { diff --git a/include/fmt/format.h b/include/fmt/format.h index af589ea3..bb9bc1e5 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -138,6 +138,18 @@ FMT_END_NAMESPACE # endif #endif +#ifndef FMT_USE_FLOAT +# define FMT_USE_FLOAT 1 +#endif + +#ifndef FMT_USE_DOUBLE +# define FMT_USE_DOUBLE 1 +#endif + +#ifndef FMT_USE_LONG_DOUBLE +# define FMT_USE_LONG_DOUBLE 1 +#endif + // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519 #if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER @@ -1893,11 +1905,10 @@ class arg_formatter_base { template ::value)> iterator operator()(T value) { - if (const_check(!is_supported_floating_point(value))) { + if (const_check(is_supported_floating_point(value))) + writer_.write(value, specs_ ? *specs_ : format_specs()); + else FMT_ASSERT(false, "unsupported float argument type"); - return out(); - } - writer_.write(value, specs_ ? *specs_ : format_specs()); return out(); }