From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 668623858D28; Wed, 30 Aug 2023 15:16:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 668623858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693408576; bh=+qEXrLH2kt7gLUnfjPuW2gjge6Nn8UarRPrm/ndq6Ik=; h=From:To:Subject:Date:From; b=bRY8HMieJgmjISpAjNnFzE7I/1bYifCl6TY0713fWv46HbA/CWzQRBOpibrNicL5U rjSQ1LC2k1TLg8gNfm0kVuHEb4SmThM0X1CYgVUriutqRWS3RYsXfRB9Nj5Tc3JgOR ZpFw0SIHAaGs0t3ts+MA07TDvhpcLV90bAY3FamA= From: "bruce at momjian dot us" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/111240] New: Incorrect warning from -Wmaybe-uninitialized Date: Wed, 30 Aug 2023 15:16:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruce at momjian dot us X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111240 Bug ID: 111240 Summary: Incorrect warning from -Wmaybe-uninitialized Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: bruce at momjian dot us Target Milestone: --- Compiling this file from the PostgreSQL master source tree generates a warn= ing when I don't think it should. To reproduce, only -O1 produces the bug, not -O0/-O2/-O3: gcc -Wmaybe-uninitialized -O1 -c clauses.i Yields: clauses.c: In function =E2=80=98recheck_cast_function_args=E2=80=99: clauses.c:4293:19: warning: =E2=80=98actual_arg_types=E2=80=99 may be used = uninitialized [-Wmaybe-uninitialized] 4293 | rettype =3D enforce_generic_type_consistency(actual_arg_typ= es, In file included from clauses.c:45: ../../../../src/include/parser/parse_coerce.h:82:17: note: by argument 1 of type =E2=80=98const Oid *=E2=80=99 {aka =E2=80=98const unsigned int *=E2=80= =99} to =E2=80=98enforce_generic_type_consistency=E2=80=99 declared here 82 | extern Oid enforce_generic_type_consistency(const Oid *actual_arg_types, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ clauses.c:4279:24: note: =E2=80=98actual_arg_types=E2=80=99 declared here 4279 | Oid actual_arg_types[FUNC_MAX_ARGS]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the C code. nargs prevents uninitialized values from being used wh= en calling enforce_generic_type_consistency(). ------------------------------------- static void recheck_cast_function_args(List *args, Oid result_type, Oid *proargtypes, int pronargs, HeapTuple func_tuple) { Form_pg_proc funcform =3D (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 =3D 0; foreach(lc, args) { actual_arg_types[nargs++] =3D exprType((Node *) lfirst(lc)); } Assert(nargs =3D=3D pronargs); memcpy(declared_arg_types, proargtypes, pronargs * sizeof(Oid)); rettype =3D enforce_generic_type_consistency(actual_arg_types, declared_arg_types, nargs, funcform->prorettype, false);=