Re: Windows build warnings - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: Windows build warnings
Date
Msg-id 91A79E99-2F4D-46AE-9145-ECAFC5F72781@yesql.se
Whole thread Raw
In response to Re: Windows build warnings  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Windows build warnings
List pgsql-hackers
> On 22 Nov 2021, at 16:06, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Alvaro Herrera <alvherre@alvh.no-ip.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/




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Building postgresql armv7 on emulated x86_64
Next
From: Alvaro Herrera
Date:
Subject: Re: small change to comment for ATExecDetachPartition