From d2387999ece1117527d93f947e9cc3436c1881a3 Mon Sep 17 00:00:00 2001 From: vitaut Date: Sat, 28 Mar 2015 17:52:17 -0700 Subject: [PATCH] Try fixing a bogus MSVC warning about buffer overrun (#145) --- format.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/format.h b/format.h index bae04444..3a82f827 100644 --- a/format.h +++ b/format.h @@ -2601,12 +2601,18 @@ inline void format_decimal(char *&buffer, T value) { namespace fmt { namespace internal { -inline void set_types(Arg *) {} +inline void do_set_types(Arg *) {} template -inline void set_types(Arg *args, const T &arg, const Args & ... tail) { +inline void do_set_types(Arg *args, const T &arg, const Args & ... tail) { args->type = static_cast(MakeValue::type(arg)); - set_types(args + 1, tail...); + do_set_types(args + 1, tail...); +} + +template +inline void set_types(Arg *array, const Args & ... args) { + do_set_types(array, args...); + array[sizeof...(Args)].type = Arg::NONE; } // Computes the argument array size by adding 1 to N, which is the number of @@ -2628,10 +2634,8 @@ struct ArgArraySize { Arg array[fmt::internal::ArgArraySize::VALUE] = { \ fmt::internal::MakeValue(args)... \ }; \ - if (sizeof...(Args) > fmt::ArgList::MAX_PACKED_ARGS) { \ + if (sizeof...(Args) > fmt::ArgList::MAX_PACKED_ARGS) \ set_types(array, args...); \ - array[sizeof...(Args)].type = Arg::NONE; \ - } \ call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), \ fmt::ArgList(fmt::internal::make_type(args...), array)); \ }