some extra warnings from MSVC

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: some extra warnings from MSVC
Date: 2026-04-11 10:37:15
Message-ID: 1142ad86-e475-41b3-aeee-c6ad913064fa@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I ran the MSVC build with the warning level set one level higher than
the default (that is, meson -Dwarning_level=2, which actually maps to
what MSVC considers its level 3), and it gave two new warnings that
should be fixed:

../src/backend/utils/error/elog.c(1255): warning C4013: 'wchar2char'
undefined; assuming extern returning int

../src/backend/utils/hash/dynahash.c(1767): warning C4334: '<<': result
of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

These are both in code that is new in PG19.

The first one is from commit 65707ed9afc (Add backtrace support for
Windows). This would be an error in gcc (from C99 on); it's kind of
incredible that MSVC doesn't even warn about this by default. I propose
to add this warning category to the default set.

(Second thought: For consistency, make this an error, with '/we4013'
instead of '/w24013'.)

The second one is from commit 13b935cd521 (Change dynahash.c and
hsearch.h to use int64 instead of long). I don't have a patch here to
include this in the default warning set, mainly because it doesn't
appear to map to any gcc warning option, but maybe we should add it
anyway, since it can catch this kind of 4-byte-long-on-Windows issue.

Attachment Content-Type Size
0001-MSVC-Add-warning-for-missing-function-declaration.patch text/plain 851 bytes
0002-MSVC-Add-missing-include.patch text/plain 784 bytes
0003-Fix-64-bit-shifting-in-dynahash.c.patch text/plain 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dapeng Wang 2026-04-11 12:19:55 Re: Add missing CHECK_FOR_INTERRUPTS in autovacuum catalog scan loops
Previous Message jian he 2026-04-11 08:36:51 Re: FOR PORTION OF does not recompute GENERATED STORED columns that depend on the range column