From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B750E3858D35; Tue, 7 May 2024 02:42:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B750E3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715049723; bh=DFVuVJbJYdsYHDDYP7O7gJvzHsBdWDWvwW7OZIUm/sw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ijuclew7p5TEDXvQSQDOJV+LpSuqeRocWggIrVrPB+S/CyGNxKqVklBDRlVcBHcWH YAw60+GGd4OSWrY/wljAd9CPgbT4w0/LJipbdQh2fx5nwv1NQBfmUyYmsthTMr7MPp JKKN5SZ4GTqOMTjacjS89HNPNM5fPH7CFeDMzKIA= From: "modchipv12 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/89990] request warning: Use of out of scope compound literals Date: Tue, 07 May 2024 02:42:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: modchipv12 at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: Message-ID: In-Reply-To: References: 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=3D89990 --- Comment #7 from Andrew D'Addesio --- (In reply to Andrew Pinski from comment #6) > The warning is now included in GCC 12. > And this makes this a dup of bug 63272. >=20 > *** This bug has been marked as a duplicate of bug 63272 *** Yep, the new warning is working nicely on my test case (comment #5) on GCC 14.0.1 on Fedora 40 x86-64: test.c: In function =E2=80=98test=E2=80=99: test.c:22:15: warning: dangling pointer =E2=80=98ptr=E2=80=99 to an unn= amed temporary may be used [-Wdangling-pointer=3D] 22 | return ptr->c; | ~~~^~~ test.c:15:37: note: unnamed temporary defined here 15 | ptr =3D &(const struct mytype){ 43 }; | ^ Though one thing to note -- (in addition to the above warning) it still generates that "strange" -Wuninitialized warning if and only if there are o= ne or fewer calls to foo(): In function =E2=80=98test=E2=80=99, inlined from =E2=80=98main=E2=80=99 at test.c:27:12: test.c:22:15: warning: =E2=80=98.c=E2=80=99 is used uninitialize= d [-Wuninitialized] 22 | return ptr->c; | ~~~^~~ ^ If foo() is called 2+ times then that warning disappears. It's not a bug per se as the "real" -Wdangling-pointer warning still gets displayed to the user (Ufe10 is probably GCC's representation of the variab= le that was never initialized). But I find it very peculiar that the threshold for silencing that -Wuninitialized warning is 2 function calls and not say 1 or 10. This actually has gotten me curious. Would you have an idea/explanation beh= ind that 2 function call threshold @Andrew Pinski?=