From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 20DCE385771B; Fri, 2 Jun 2023 12:01:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20DCE385771B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685707260; bh=iw8QmzF7kK+51l8EwdVbggP7r5za9S/IfBYdQBi+bMw=; h=From:To:Subject:Date:From; b=poH2XxlSQVA7HJZs0y6tJ3bM5yt1VzVG1x1W5GV13P4NXfEU9ZFerMhHzPMsZ50lv +vWMEfy9K3jCT70ezxA3mdPB4xHanqRf1E2YZgXaV3DfSJUHFxsUEjGu2oPmKYOsA9 EjG7/SKglus9nNWeDCMkGKkO7gdikXrLV2AYidhw= From: "patrickdepinguin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110091] New: bogus -Wdangling-pointer on non-pointer values Date: Fri, 02 Jun 2023 12:00:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: patrickdepinguin at gmail dot com 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=3D110091 Bug ID: 110091 Summary: bogus -Wdangling-pointer on non-pointer values Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: patrickdepinguin at gmail dot com Target Milestone: --- Following reduced testcase gives a bogus -Wdangling-pointer: struct tEntry { int value; }; struct tOut { int outvalue; }; extern struct tOut *out; extern int otherfunc(struct tEntry *); extern void anotherfunc(int val); void bar() { struct tEntry entry =3D { 0 }; if (otherfunc(&entry) !=3D 0) { return; } if (out) { out->outvalue =3D entry.value; } anotherfunc(5); } void foo() { bar(); } $ gcc -O2 -Wall -Werror /opt/test.c /opt/test.c: In function 'bar': /opt/test.c:26:30: error: dangling pointer to 'entry' may be used [-Werror=3Ddangling-pointer=3D] 26 | out->outvalue =3D entry.value; | ~~~~~^~~~~~ /opt/test.c:17:19: note: 'entry' declared here 17 | struct tEntry entry =3D { 0 }; | ^~~~~ In function 'bar', inlined from 'foo' at /opt/test.c:34:5: /opt/test.c:26:30: error: dangling pointer to 'entry' may be used [-Werror=3Ddangling-pointer=3D] 26 | out->outvalue =3D entry.value; | ~~~~~^~~~~~ /opt/test.c: In function 'foo': /opt/test.c:17:19: note: 'entry' declared here 17 | struct tEntry entry =3D { 0 }; | ^~~~~ cc1: all warnings being treated as errors entry is a local struct, initialized to 0, and passed as pointer to an exte= rnal function. But the use being warned about is not using any pointer. Tested with 12.2.0 (Debian), 12.2.1 (Gentoo), 12.3.0 (official gcc docker image), 13.1.0 (official gcc docker image).=