From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 238EA3858402; Tue, 14 Sep 2021 16:49:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 238EA3858402 From: "hv at crypt dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102329] New: pointer "maybe uninitialized" right after assignment Date: Tue, 14 Sep 2021 16:49:11 +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: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hv at crypt dot org 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 16:49:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102329 Bug ID: 102329 Summary: pointer "maybe uninitialized" right after assignment Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hv at crypt dot org Target Milestone: --- Reduced from perl source code: % cat test.c extern void *malloc (long unsigned int size); extern void f1 (const void *pointer); void perl_alloc(void) { void *vp1 =3D malloc(1); /* *(char*)vp1 =3D 0; */ f1((const void *)vp1); } % gcc-11.2.0 -c -Wmaybe-uninitialized -O2 test.c test.c: In function 'perl_alloc': test.c:7:5: warning: 'vp1' may be used uninitialized [-Wmaybe-uninitialized] 8 | f1((const void *)vp1); | ^~~~~~~~~~~~~~~~~~~~~ test.c:2:13: note: by argument 1 of type 'const void *' to 'f1' declared he= re 3 | extern void f1 (const void *pointer); | ^~ %=20 This build of gcc was configured as follows (including the error in prefix): ../gcc/configure --prefix=3D/opt/gcc-12 --disable-gcov --disable-multilib --enable-languages=3Dc --disable-nls --disable-decimal-float No warning is seen under my system "gcc-9 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102", nor does 11.2.0 complain if the commented-out assignment is uncommented, nor if 'malloc' is renamed to 'f2', nor if 'const' is removed = from the signature of f1 along with the corresponding cast. Is the warning intended to imply that the memory pointed to by vp1 may be uninitialized, rather than vp1 itself? If so, perhaps it is only that the message is misleadingly worded, and making possibly inappropriate assumptio= ns about what f1() may do.=