On 2026-07-04 10:38, Tom Lane wrote:
I'm not really following your aversion to a cast. Surely none of these constants will ever come close to exceeding INT_MAX.
Although a cast would be safe in this case, verifying that it's safe requires too much thinking. I want a knowledgeable reader to be able to look at just that line of code and trivially say "yeah, that's benign" while muttering a few choice words about clueless compilers. How about replacing "+" with "~~"? That is, something like the first attached draft patch. It pacifies gcc -Wenum-compare. Does it also pacify MSVC? If so, I can install it.
the unsigned warning isn't only on old MSVC versions. I see it also on the latest that we have in the Postgres buildfarm, 19.50.35726
Ah, OK, I misunderstood. Does the second attached draft patch pacify MSVC? If so, I can install it too. I took a quick look at the postgres copy of zic.c and have a couple of thoughts. First, most of the changes are indenting or comment reformatting and whatnot, which makes it hard to see what's going on. Do you know offhand whether there are any functional changes that tzcode should buy back? If so, are those changes public domain? Second, I don't envy you the job of merging tzcode's zic.c changes into postgres. If there are no functional changes, how about the idea of postgres instead compiling a file pgzic.c that looks something like this: #include "postgres_fe.h" #include "pg_getopt.h" /* Any other Postgres-specific stuff goes here. */ #include "zic.c" /* A byte-for-byte copy of tzcode zic.c. */ ... and using that for the Postgres zic? I could make some changes to tzcode zic.c to make this happen, much as I already did (and want to continue to do) for FreeBSD.