From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: -Wuninitialized when binding a ref to uninit DM [PR113987]
Date: Thu, 22 Feb 2024 14:28:41 -0500 [thread overview]
Message-ID: <ZdegaTebcdh-M2yI@redhat.com> (raw)
In-Reply-To: <3dae04f1-90b7-4a03-b239-24df37c57cdf@redhat.com>
On Thu, Feb 22, 2024 at 08:34:45AM +0000, Jason Merrill wrote:
> On 2/20/24 19:15, Marek Polacek wrote:
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
> >
> > -- >8 --
> > This PR asks that our -Wuninitialized for mem-initializers does
> > not warn when binding a reference to an uninitialized data member.
> > We already check !INDIRECT_TYPE_P in find_uninit_fields_r, but
> > that won't catch binding a parameter of a reference type to an
> > uninitialized field, as in:
> >
> > struct S { S (int&); };
> > struct T {
> > T() : s(i) {}
> > S s;
> > int i;
> > };
> >
> > This patch adds a new function to handle this case.
>
> For type_build_ctor_call types like S, it's weird that we currently
> find_uninit_fields before building the initialization. What if we move the
> check after the build_aggr_init so we have the actual initializer instead of
> just the expression?
Thanks. I've tried but unfortunately I'm not getting anywhere. One
problem is that immediately after the find_uninit_fields call we may
change the TREE_LIST in
if (init && TREE_CODE (init) == TREE_LIST)
//...
so we'd have to cope with that somehow. Sinking find_uninit_fields
into one of the conditions below looks like a complication. Another
problem is that calling find_uninit_fields on the result of
build_aggr_init call causes a bogus warning: we create something like
E::E (&((struct F *) this)->e, ((struct F *) this)->a)
and then warn that the this object is uninitialized. So I'm not sure
if that fix would be simpler.
Marek
next prev parent reply other threads:[~2024-02-22 19:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 0:15 Marek Polacek
2024-02-22 8:34 ` Jason Merrill
2024-02-22 19:28 ` Marek Polacek [this message]
2024-02-28 23:21 ` Jason Merrill
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=ZdegaTebcdh-M2yI@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).