From 948e846cccca1572a8b5a5e469574508e2d8973e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 4 Jul 2026 11:20:04 -0700
Subject: [DRAFT 2/2] Pacify MSVC when negating unsigned

Problem reported by Tom Lane for MSVC 19.50.35726 in:
https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/PJBVERYHQZEXIREYIHC5OJGZMNVQC2SD/
* zic.c (random_dirent): Pacify with 0-X instead of -X.
---
 zic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/zic.c b/zic.c
index e049303d..31b72d2a 100644
--- a/zic.c
+++ b/zic.c
@@ -1571,8 +1571,8 @@ random_dirent(char const **name, char **namealloc)
      uintmax_t value that is this value or greater, yields a biased
      remainder when divided by BASE**6.  UNFAIR_MIN equals the
      mathematical value of ((UINTMAX_MAX + 1) - (UINTMAX_MAX + 1) % BASE**6)
-     computed without overflow.  */
-  uint_fast64_t unfair_min = - ((UINTMAX_MAX % base__6 + 1) % base__6);
+     computed without overflow.  The 0 pacifies MSVC C4146.  */
+  uint_fast64_t unfair_min = 0 - ((UINTMAX_MAX % base__6 + 1) % base__6);
 
   if (!dst) {
     char *cp = dst = xmalloc(size_sum(dirlen, prefixlen + suffixlen + 1));
-- 
2.53.0

