pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
5+ messages / 4 participants
[nested] [flat]

* Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
@ 2026-06-04 15:07  Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Nathan Bossart @ 2026-06-04 15:07 UTC (permalink / raw)
  To: Hans Buschmann <buschmann@nidsa.net>; +Cc: pgsql-hackers

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.
Does something like this suppress the warning?

	Oid			actual_arg_types[FUNC_MAX_ARGS] = {InvalidOid};

-- 
nathan





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

*  Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
@ 2026-06-04 22:24  Tristan Partin <tristan@partin.io>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Tristan Partin @ 2026-06-04 22:24 UTC (permalink / raw)
  To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: pgsql-hackers; Hans Buschmann <buschmann@nidsa.net>

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)





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
@ 2026-06-12 14:54  Álvaro Herrera <alvherre@kurilemu.de>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Álvaro Herrera @ 2026-06-12 14:54 UTC (permalink / raw)
  To: Nathan Bossart <nathandbossart@gmail.com>; +Cc: Hans Buschmann <buschmann@nidsa.net>; pgsql-hackers

On 2026-Jun-04, 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.
> Does something like this suppress the warning?
> 
> 	Oid			actual_arg_types[FUNC_MAX_ARGS] = {InvalidOid};

I agree that it doesn't look like there's a real problem, and that
something like what you suggest should silence this warning.  I mildly
prefer to do " = {0}" though, the rules for C incomplete initializers
being so weird.  But I wouldn't oppose this patch as posted.

BTW we seem to do pretty much the same thing in ParseFuncOrColumn(),
right?

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"People get annoyed when you try to debug them."  (Larry Wall)





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
@ 2026-06-17 14:39  Nathan Bossart <nathandbossart@gmail.com>
  parent: Álvaro Herrera <alvherre@kurilemu.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Nathan Bossart @ 2026-06-17 14:39 UTC (permalink / raw)
  To: Álvaro Herrera <alvherre@kurilemu.de>; +Cc: Hans Buschmann <buschmann@nidsa.net>; pgsql-hackers

On Fri, Jun 12, 2026 at 04:54:04PM +0200, Álvaro Herrera wrote:
> On 2026-Jun-04, Nathan Bossart wrote:
>> This code is ~18 years old, so I'm dubious there's a real problem here.
>> Does something like this suppress the warning?
>> 
>> 	Oid			actual_arg_types[FUNC_MAX_ARGS] = {InvalidOid};
> 
> I agree that it doesn't look like there's a real problem, and that
> something like what you suggest should silence this warning.  I mildly
> prefer to do " = {0}" though, the rules for C incomplete initializers
> being so weird.  But I wouldn't oppose this patch as posted.

WFM.  Hans, can you confirm this fixes the issue?

-- 
nathan





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c
@ 2026-06-17 15:27  Erik Rijkers <er@xs4all.nl>
  parent: Nathan Bossart <nathandbossart@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Erik Rijkers @ 2026-06-17 15:27 UTC (permalink / raw)
  To: Nathan Bossart <nathandbossart@gmail.com>; Álvaro Herrera <alvherre@kurilemu.de>; +Cc: Hans Buschmann <buschmann@nidsa.net>; pgsql-hackers

Op 6/17/26 om 16:39 schreef Nathan Bossart:
> On Fri, Jun 12, 2026 at 04:54:04PM +0200, Álvaro Herrera wrote:
>> On 2026-Jun-04, Nathan Bossart wrote:
>>> This code is ~18 years old, so I'm dubious there's a real problem here.
>>> Does something like this suppress the warning?
>>>
>>> 	Oid			actual_arg_types[FUNC_MAX_ARGS] = {InvalidOid};
>>
>> I agree that it doesn't look like there's a real problem, and that
>> something like what you suggest should silence this warning.  I mildly
>> prefer to do " = {0}" though, the rules for C incomplete initializers
>> being so weird.  But I wouldn't oppose this patch as posted.
> 
> WFM.  Hans, can you confirm this fixes the issue?
> 

FWIW, it silences that warning on my gcc 16.1.0

Erik





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-06-17 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-04 15:07 Re: PG19beta1: GCC 16.1.1 warning: ‘actual_arg_types’ may be used uninitialized in clauses.c Nathan Bossart <nathandbossart@gmail.com>
2026-06-04 22:24 ` Tristan Partin <tristan@partin.io>
2026-06-12 14:54 ` Álvaro Herrera <alvherre@kurilemu.de>
2026-06-17 14:39   ` Nathan Bossart <nathandbossart@gmail.com>
2026-06-17 15:27     ` Erik Rijkers <er@xs4all.nl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox