AW: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c

From: Hans Buschmann <buschmann(at)nidsa(dot)net>
To: Tristan Partin <tristan(at)partin(dot)io>, Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: AW: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
Date: 2026-06-05 07:15:29
Message-ID: d891f1b260ae462aa2548b8aaf3f460d@nidsa.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I only want to add that my system is current up to date (dnf check-update --refresh), The GCC is installed from Fedora during the normal system upgrade process to Fedora 44.

root(at)fedora ~]# dnf list --installed gcc*
Installed packages (available for reinstall, available for upgrade)

gcc.x86_64 16.1.1-2.fc44 updates
gcc-c++.x86_64 16.1.1-2.fc44 updates
gcc-plugin-annobin.x86_64 16.1.1-2.fc44 updates

As seen in the Bug report, this is not specific to PG 19 beta1.

My guess is that this warning occurs on all supported versions of postgres (tested with 18.4 in the BUG report), so backpatching could be necessary.

Hans Buschmann

________________________________
Von: Tristan Partin <tristan(at)partin(dot)io>
Gesendet: Freitag, 5. Juni 2026 00:24
An: Nathan Bossart
Cc: pgsql-hackers(at)postgresql(dot)org; Hans Buschmann
Betreff: Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c

On Thu Jun 4, 2026 at 3:08 PM UTC, Nathan Bossart wrote:
> On Thu, Jun 04, 2026 at 02:42:18PM +0000, Hans Buschmann wrote:
>> 839/2360] Compiling C object src/backend/postgres_lib.a.p/optimizer_util_clauses.c.o
>> ../src/backend/optimizer/util/clauses.c: In function ‘recheck_cast_function_args.isra’:
>> ../src/backend/optimizer/util/clauses.c:5152:19: warning: ‘actual_arg_types’ may be used uninitialized [-Wmaybe-uninitialized]
>> 5152 | rettype = enforce_generic_type_consistency(actual_arg_types,
>
> This code is ~18 years old, so I'm dubious there's a real problem here.

Pulling the code into the email:

> static void
> recheck_cast_function_args(List *args, Oid result_type,
> Oid *proargtypes, int pronargs,
> HeapTuple func_tuple)
> {
> [...]
> Oid actual_arg_types[FUNC_MAX_ARGS];
> [...]
> ListCell *lc;
>
> if (list_length(args) > FUNC_MAX_ARGS)
> elog(ERROR, "too many function arguments");
> nargs = 0;
> foreach(lc, args)
> {
> actual_arg_types[nargs++] = exprType((Node *) lfirst(lc));
> }
> Assert(nargs == pronargs);
> memcpy(declared_arg_types, proargtypes, pronargs * sizeof(Oid));
> rettype = enforce_generic_type_consistency(actual_arg_types,

GCC seems right to complain. A NIL list or a list with a length of 0
would initialize none of the elements in actual_arg_types. However, is
this a problem in actuality? No, because we use nargs to make sure we
don't access uninitialized memory in
enforce_generic_type_consistency(). Maybe GCC's static analysis is a lot
smarter than I give it credit for though, and this is a compiler bug in
the newer version.

> Does something like this suppress the warning?
>
> Oid actual_arg_types[FUNC_MAX_ARGS] = {InvalidOid};

I could not reproduce on 16.1.0 via nixpkgs or 16.1.1 on Fedora 44
(which is strange), but theoretically this would work.

--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-06-05 07:35:52 Re: [Bug]Assertion failure in LATERAL GRAPH_TABLE with multi-label pattern
Previous Message Peter Eisentraut 2026-06-05 07:10:47 Re: Fix DROP PROPERTY GRAPH "unsupported object class" error