This patch is really not necessary from a functional point of view. It is only necessary if we want to silence a compiler warning.
Tested on `gcc (GCC) 13.1.1 20230511 (Red Hat 13.1.1-2)`. After silencing this warning, all I am left with (given my build configuration) is: [1667/2280] Compiling C object src/pl/plpgsql/src/plpgsql.so.p/pl_exec.c.o In file included from ../src/include/access/htup_details.h:22, from ../src/pl/plpgsql/src/pl_exec.c:21: In function ‘assign_simple_var’, inlined from ‘exec_set_found’ at ../src/pl/plpgsql/src/pl_exec.c:8349:2: ../src/include/varatt.h:230:36: warning: array subscript 0 is outside array bounds of ‘char[0]’ [-Warray-bounds=] 230 | (((varattrib_1b_e *) (PTR))->va_tag) | ^ ../src/include/varatt.h:94:12: note: in definition of macro ‘VARTAG_IS_EXPANDED’ 94 | (((tag) & ~1) == VARTAG_EXPANDED_RO) | ^~~ ../src/include/varatt.h:284:57: note: in expansion of macro ‘VARTAG_1B_E’ 284 | #define VARTAG_EXTERNAL(PTR) VARTAG_1B_E(PTR) | ^~~~~~~~~~~ ../src/include/varatt.h:301:57: note: in expansion of macro ‘VARTAG_EXTERNAL’ 301 | (VARATT_IS_EXTERNAL(PTR) && !VARTAG_IS_EXPANDED(VARTAG_EXTERNAL(PTR))) | ^~~~~~~~~~~~~~~ ../src/pl/plpgsql/src/pl_exec.c:8537:17: note: in expansion of macro ‘VARATT_IS_EXTERNAL_NON_EXPANDED’ 8537 | VARATT_IS_EXTERNAL_NON_EXPANDED(DatumGetPointer(newvalue))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >From my perspective, this warning definitely seems like a false positive, but I don't know the code well-enough to say that for certain. -- Tristan Partin Neon (https://neon.tech)
From 0daab1d0231668da4ac701bd240fc1da5fbcd5bb Mon Sep 17 00:00:00 2001 From: Tristan Partin <tris...@neon.tech> Date: Wed, 7 Jun 2023 09:21:59 -0500 Subject: [PATCH v1] Fix last remaining uninitialized memory warnings gcc fails to properly analyze the code due to the loop stop condition including `l != NULL`. Let's just help it out. --- src/bin/pgbench/pgbench.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 1d1670d4c2..536f1721ff 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -2247,7 +2247,7 @@ evalStandardFunc(CState *st, { /* evaluate all function arguments */ int nargs = 0; - PgBenchValue vargs[MAX_FARGS]; + PgBenchValue vargs[MAX_FARGS] = { 0 }; PgBenchExprLink *l = args; bool has_null = false; -- -- Tristan Partin Neon (https://neon.tech)