Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qai3H-00ABIU-Rs for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Aug 2023 19:37:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qai3F-00F7li-6b for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Aug 2023 19:37:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qai3E-00F7la-So for pgsql-hackers@lists.postgresql.org; Mon, 28 Aug 2023 19:37:28 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qai37-001T8N-DN for pgsql-hackers@postgresql.org; Mon, 28 Aug 2023 19:37:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2023062407; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:Content-ID: Content-Description:In-Reply-To:References; bh=5BboRHj5IMHWJhonmWT94dszWp7ycZ9/24b5coxcasY=; b=oAkGwyIYrKe2Wpx8bV7GVTxEsv ws83e4uANbEVoubWLTFP0IrqrK4GOST8m+QSYTKrpfMRLbse/C3/iQs1c9UD/xLjBHq0fRsSIMctZ hnEiQKzJ1YrazGGkoslpQcXDvDmqHAjroHajMs+PZt2XYJnTVx4PyTaPIWmHpNxM8p4mAUlBK9v8H kBs7u9oqsvmiFvOvC9u/BccX5N/mrkVvj8zoCopB3AeMcwT8rMydn5TvmmB7CRuSwpOMtCZ89azMh 5fnS/0G6vu9m1l2NFnJ+W+AwS8EKzy7ODeAYZiyOMzgAko2WrX8VM/lciBtOL6Zs3XubEJ8wTH0Ni 3cqi5/lQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1qai36-00FLhz-19 for pgsql-hackers@postgresql.org; Mon, 28 Aug 2023 15:37:20 -0400 Date: Mon, 28 Aug 2023 15:37:20 -0400 From: Bruce Momjian To: PostgreSQL-development Subject: Debian 12 gcc warning Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Debian 12, gcc version 12.2.0 (Debian 12.2.0-14) generates a warning on PG 13 to current, but only with -O1 optimization level, and not at -O0/-O2/-O3: clauses.c: In function ‘recheck_cast_function_args’: clauses.c:4293:19: warning: ‘actual_arg_types’ may be used uninitialized [-Wmaybe-uninitialized] 4293 | rettype = enforce_generic_type_consistency(actual_arg_types, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4294 | declared_arg_types, | ~~~~~~~~~~~~~~~~~~~ 4295 | nargs, | ~~~~~~ 4296 | funcform->prorettype, | ~~~~~~~~~~~~~~~~~~~~~ 4297 | false); | ~~~~~~ In file included from clauses.c:45: ../../../../src/include/parser/parse_coerce.h:82:17: note: by argument 1 of type ‘const Oid *’ {aka ‘const unsigned int *’} to ‘enforce_generic_type_consistency’ declared here 82 | extern Oid enforce_generic_type_consistency(const Oid *actual_arg_types, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ clauses.c:4279:33: note: ‘actual_arg_types’ declared here 4279 | Oid actual_arg_types[FUNC_MAX_ARGS]; | ^~~~~~~~~~~~~~~~ The code is: static void recheck_cast_function_args(List *args, Oid result_type, Oid *proargtypes, int pronargs, HeapTuple func_tuple) { Form_pg_proc funcform = (Form_pg_proc) GETSTRUCT(func_tuple); int nargs; Oid actual_arg_types[FUNC_MAX_ARGS]; Oid declared_arg_types[FUNC_MAX_ARGS]; Oid rettype; 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, declared_arg_types, nargs, funcform->prorettype, false); /* let's just check we got the same answer as the parser did ... */ I don't see a clean way of avoiding the warning except by initializing the array, which seems wasteful. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.