From a21a206c89409c3d1418e1e69e0562f621517dcf Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 14 Oct 2024 00:03:54 +0300 Subject: [PATCH] [UCRT] Add workaround for va_arg warning about type promotion --- .../ucrt/inc/corecrt_internal_stdio_output.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sdk/lib/ucrt/inc/corecrt_internal_stdio_output.h b/sdk/lib/ucrt/inc/corecrt_internal_stdio_output.h index cde4af0e080..bb4d545d88c 100644 --- a/sdk/lib/ucrt/inc/corecrt_internal_stdio_output.h +++ b/sdk/lib/ucrt/inc/corecrt_internal_stdio_output.h @@ -30,16 +30,33 @@ namespace __crt_stdio_output { // reads the next argument of type T from the varargs list and updates the // va_list, just like va_arg does. The 'peek' function returns the next argument // of type T, but does not modify the va_list. +#if defined(__GNUC__) || defined(__clang__) +template struct _va_arg_promoted_tye { using type = T; }; +template<> struct _va_arg_promoted_tye { using type = int; }; +template<> struct _va_arg_promoted_tye { using type = int; }; +template<> struct _va_arg_promoted_tye { using type = int; }; +template<> struct _va_arg_promoted_tye { using type = int; }; +template<> struct _va_arg_promoted_tye { using type = int; }; +#endif + template T read_va_arg(va_list& arglist) throw() { +#if defined(__GNUC__) || defined(__clang__) + return (T)(va_arg(arglist, typename _va_arg_promoted_tye::type)); +#else return va_arg(arglist, T); +#endif } template T peek_va_arg(va_list arglist) throw() { +#if defined(__GNUC__) || defined(__clang__) + return (T)(va_arg(arglist, typename _va_arg_promoted_tye::type)); +#else return va_arg(arglist, T); +#endif }