Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions
Date: 2026-06-20 07:40:33
Message-ID: ajZD8TCSIYPJgCNJ@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

When using -DMEMORY_CONTEXT_CHECKING, (also enforced by
-DUSE_VALGRIND), I am getting a couple of compiler warnings when
building without assertions:
aset.c: In function ‘AllocSetCheck’:
aset.c:1686:25: warning: variable ‘total_allocated’ set but not used
[-Wunused-but-set-variable=]
1686 | Size total_allocated = 0;
| ^~~~~~~~~~~~~~~
bump.c: In function ‘BumpCheck’:
bump.c:772:25: warning: variable ‘total_allocated’ set but not used
[-Wunused-but-set-variable=]
772 | Size total_allocated = 0;
| ^~~~~~~~~~~~~~~
generation.c: In function ‘GenerationCheck’:
generation.c:1137:25: warning: variable ‘total_allocated’ set but not
used [-Wunused-but-set-variable=]
1137 | Size total_allocated = 0;
| ^~~~~~~~~~~~~~~
slab.c: In function ‘SlabCheck’:
slab.c:1041:33: warning: variable ‘nblocks’ set but not used
[-Wunused-but-set-variable=]
1041 | int nblocks = 0;
| ^~~~~~~

All these ought to be marked with a PG_USED_FOR_ASSERTS_ONLY. Not
sure why nobody has seen that yet? I am using a gcc 16.1.1, nothing
fancy AFAIK.

Regards,
--
Michael

Attachment Content-Type Size
assert-only.patch text/plain 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-06-20 07:45:55 Re: Unexpected behavior after OOM errors
Previous Message Alexander Lakhin 2026-06-20 07:00:01 Re: [PATCH] O_CLOEXEC not honored on Windows - handle inheritance chain