Re: Windows build warnings

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Greg Nancarrow <gregn4422@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-11-26T09:12:30Z
Lists: pgsql-hackers
> On 26 Nov 2021, at 05:45, Tom Lane <tgl@sss.pgh.pa.us> wrote:

>> Personally I'm not really in favour of outright disabling the C4101
>> warning on Windows, because I think it is a useful warning for
>> Postgres developers on Windows for cases unrelated to the use of
>> PG_USED_FOR_ASSERTS_ONLY.

I'm not sure I find it useful, as the only reason I *think* I know what it's
doing is through trial and error.  The only warnings we get from a tree where
PG_USED_FOR_ASSERTS_ONLY clearly does nothing, are quite uninteresting and
fixing them only amounts to silencing the compiler and not improving the code.

> IMO we should either do that or do whatever's necessary to make the
> macro work properly on MSVC.  I'm not very much in favor of jumping
> through hoops to satisfy a compiler that has a randomly-different-
> but-still-demonstrably-inadequate version of this warning.

Since there is no equivalent attribute in MSVC ([[maybe_unused]] being a C++17
feature) I propose that we silence the warning.  If someone comes along with an
implementation of PG_USED_FOR_ASSERTS_ONLY we can always revert that then.

--
Daniel Gustafsson		https://vmware.com/




Commits

  1. Disable unused-variable warning C4101 in MSVC

  2. Remove PF_USED_FOR_ASSERTS_ONLY from variables in general use

  3. Fix handling of non-key columns get_index_column_opclass()