From e7b1cc6a5b3b1446b5aaf692a80111982f0f88e3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 11 Jul 2026 14:11:45 +0200 Subject: [PATCH 2/3] Disable MSVC warning C4146 globally --- meson.build | 1 + src/port/snprintf.c | 8 -------- src/timezone/zic.c | 7 ------- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/meson.build b/meson.build index d88a7a70308..8fe2307c1df 100644 --- a/meson.build +++ b/meson.build @@ -2317,6 +2317,7 @@ if cc.get_id() == 'msvc' # Warnings to disable: # from /W2: + '/wd4146', # unary minus operator applied to unsigned type, result still unsigned '/wd4244', # conversion from 'type1' to 'type2', possible loss of data # Additional warnings to enable: diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 2189ebfe399..c4611f6ab0b 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -1056,19 +1056,11 @@ fmtint(long long value, char type, int forcesign, int leftjust, return; /* keep compiler quiet */ } - /* disable MSVC warning about applying unary minus to an unsigned value */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4146) -#endif /* Handle +/- */ if (dosign && adjust_sign((value < 0), forcesign, &signvalue)) uvalue = -(unsigned long long) value; else uvalue = (unsigned long long) value; -#ifdef _MSC_VER -#pragma warning(pop) -#endif /* * SUS: the result of converting 0 with an explicit precision of 0 is no diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 38411220e01..b61082dfdf1 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -1658,14 +1658,7 @@ random_dirent(char const **name, char **namealloc) * value of ((UINTMAX_MAX + 1) - (UINTMAX_MAX + 1) % BASE**6) computed * without overflow. */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4146) -#endif uint_fast64_t unfair_min = -((UINTMAX_MAX % base__6 + 1) % base__6); -#ifdef _MSC_VER -#pragma warning(pop) -#endif if (!dst) { -- 2.55.0