Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions

Поиск
Список
Период
Сортировка
Искать

Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions

От:
Michael Paquier <michael@paquier.xyz>
Дата:
Вложения:
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

Re: Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions

От:
Heikki Linnakangas <hlinnaka@iki.fi>
Дата:
On 20/06/2026 13:45, Álvaro Herrera wrote:
> On 2026-Jun-20, Michael Paquier wrote:
>> When using -DMEMORY_CONTEXT_CHECKING, (also enforced by
>> -DUSE_VALGRIND), I am getting a couple of compiler warnings when
>> building without assertions:
> 
>> 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.
> 
> I saw this a few days ago too when testing for f50c329f538f, when
> enabling MEMORY_CONTEXT_CHECKING independently (without USE_VALGRIND and
> without USE_ASSERTIONS), and in that case, I even saw a compile failure
> in bump.c.  That requires a messier, uglier patch than what you have
> here.  I staged something but I thought it warranted more polish before
> posting.  I don't have it in this computer ATM sadly.

Committed Michael's patch for now. Not sure what that bigger issue with 
compilation failure that you mentioned is, but this fix seemed pretty 
straightforward.

- Heikki



Re: Compile warnings under -DMEMORY_CONTEXT_CHECKING and no assertions

От:
Michael Paquier <michael@paquier.xyz>
Дата:
Вложения:
On Wed, Nov 18, 2026 at 04:25:17PM +0200, Heikki Linnakangas wrote:
> Committed Michael's patch for now. Not sure what that bigger issue with
> compilation failure that you mentioned is, but this fix seemed pretty
> straightforward.

Ah.  Thanks for committing this one and taking care of the warnings.
I was wondering if anybody else other than me cared about these.  :)
--
Michael
FAQ