public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "modchipv12 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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 [thread overview]
Message-ID: <bug-89990-4-hRGrsHYfZG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-89990-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89990
--- Comment #7 from Andrew D'Addesio <modchipv12 at gmail dot com> ---
(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.
>
> *** 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 ‘test’:
test.c:22:15: warning: dangling pointer ‘ptr’ to an unnamed temporary may
be used [-Wdangling-pointer=]
22 | return ptr->c;
| ~~~^~~
test.c:15:37: note: unnamed temporary defined here
15 | ptr = &(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 one
or fewer calls to foo():
In function ‘test’,
inlined from ‘main’ at test.c:27:12:
test.c:22:15: warning: ‘<Ufe10>.c’ is used uninitialized [-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 variable
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 behind
that 2 function call threshold @Andrew Pinski?
next prev parent reply other threads:[~2024-05-07 2:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-89990-4@http.gcc.gnu.org/bugzilla/>
2020-03-31 2:34 ` modchipv12 at gmail dot com
2024-04-09 7:32 ` pinskia at gcc dot gnu.org
2024-04-09 7:33 ` pinskia at gcc dot gnu.org
2024-05-07 2:42 ` modchipv12 at gmail dot com [this message]
2024-05-07 4:55 ` pinskia at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-89990-4-hRGrsHYfZG@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).