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
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 6a9ea3671074..2cc6754ef4f9 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -1683,7 +1683,7 @@ AllocSetCheck(MemoryContext context)
const char *name = set->header.name;
AllocBlock prevblock;
AllocBlock block;
- Size total_allocated = 0;
+ Size total_allocated PG_USED_FOR_ASSERTS_ONLY = 0;
for (prevblock = NULL, block = set->blocks;
block != NULL;
diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c
index 9bb579935dbd..eba52f89bce4 100644
--- a/src/backend/utils/mmgr/bump.c
+++ b/src/backend/utils/mmgr/bump.c
@@ -769,7 +769,7 @@ BumpCheck(MemoryContext context)
BumpContext *bump = (BumpContext *) context;
const char *name = context->name;
dlist_iter iter;
- Size total_allocated = 0;
+ Size total_allocated PG_USED_FOR_ASSERTS_ONLY = 0;
/* walk all blocks in this context */
dlist_foreach(iter, &bump->blocks)
diff --git a/src/backend/utils/mmgr/generation.c
b/src/backend/utils/mmgr/generation.c
index 609c9bdc9a6b..0fcc79ec93f2 100644
--- a/src/backend/utils/mmgr/generation.c
+++ b/src/backend/utils/mmgr/generation.c
@@ -1134,7 +1134,7 @@ GenerationCheck(MemoryContext context)
GenerationContext *gen = (GenerationContext *) context;
const char *name = context->name;
dlist_iter iter;
- Size total_allocated = 0;
+ Size total_allocated PG_USED_FOR_ASSERTS_ONLY = 0;
/* walk all blocks in this context */
dlist_foreach(iter, &gen->blocks)
diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c
index 2ad325547fdc..9ae3f0c8c115 100644
--- a/src/backend/utils/mmgr/slab.c
+++ b/src/backend/utils/mmgr/slab.c
@@ -1038,7 +1038,7 @@ SlabCheck(MemoryContext context)
{
SlabContext *slab = (SlabContext *) context;
int i;
- int nblocks = 0;
+ int nblocks PG_USED_FOR_ASSERTS_ONLY = 0;
const char *name = slab->header.name;
dlist_iter iter;
signature.asc
Description: PGP signature
