> On 22 Nov 2021, at 16:06, Tom Lane <t...@sss.pgh.pa.us> wrote: > > Alvaro Herrera <alvhe...@alvh.no-ip.org> writes: >> .. but see >> https://postgr.es/m/cah2-wznwwu+9on9nzcnztk7ua238mctgpxyr1ty7u_msn5z...@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/