Re: Windows build warnings

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Windows build warnings
Date: 2021-11-22 15:22:20
Message-ID: 91A79E99-2F4D-46AE-9145-ECAFC5F72781@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 22 Nov 2021, at 16:06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
>> .. but see
>> https://postgr.es/m/CAH2-WznwWU+9on9nZCnZtk7uA238MCTgPxYr1Ty7U_Msn5ZGwQ@mail.gmail.com
>> where this was already discussed. I think if we're going to workaround
>> PG_USED_FOR_ASSERTS_ONLY not actually working, we may as well get rid of
>> it entirely. My preference would be to fix it so that it works on more
>> platforms (at least Windows in addition to GCC).
>
> Yeah, I do not think there is a reason to change the code if it's using
> PG_USED_FOR_ASSERTS_ONLY properly. We should either make that macro
> work on $compiler, or ignore such warnings from $compiler.

Fair enough. Looking at where we use PG_USED_FOR_ASSERTS_ONLY (and where it
works), these two warnings are the only places where we apply it to a pointer
typedef (apart from one place where the variable is indeed used outside of
asserts). Since it clearly works in all other cases, I wonder if something
like the below sketch could make MSVC handle the attribute?

diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c
index 5c0b60319d..9701c9eba0 100644
--- a/src/backend/access/heap/pruneheap.c
+++ b/src/backend/access/heap/pruneheap.c
@@ -855,7 +855,7 @@ heap_page_prune_execute(Buffer buffer,
{
Page page = (Page) BufferGetPage(buffer);
OffsetNumber *offnum;
- HeapTupleHeader htup PG_USED_FOR_ASSERTS_ONLY;
+ HeapTupleHeaderData *htup PG_USED_FOR_ASSERTS_ONLY;

/* Shouldn't be called unless there's something to do */
Assert(nredirected > 0 || ndead > 0 || nunused > 0);
@@ -867,7 +867,7 @@ heap_page_prune_execute(Buffer buffer,
OffsetNumber fromoff = *offnum++;
OffsetNumber tooff = *offnum++;
ItemId fromlp = PageGetItemId(page, fromoff);
- ItemId tolp PG_USED_FOR_ASSERTS_ONLY;
+ ItemIdData *tolp PG_USED_FOR_ASSERTS_ONLY;

#ifdef USE_ASSERT_CHECKING

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-11-22 15:39:57 Re: small change to comment for ATExecDetachPartition
Previous Message Tom Lane 2021-11-22 15:08:17 Re: Building postgresql armv7 on emulated x86_64