public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] c++: ICE with VEC_INIT_EXPR and defarg [PR106925]
Date: Wed, 12 Oct 2022 13:12:57 -0400	[thread overview]
Message-ID: <Y0b1mRBxzilqA/0n@redhat.com> (raw)
In-Reply-To: <b28369e1-ae07-86a4-eb2a-cb346e933df8@redhat.com>

On Wed, Oct 12, 2022 at 12:47:21PM -0400, Jason Merrill wrote:
> On 10/12/22 12:27, Marek Polacek wrote:
> > On Tue, Oct 11, 2022 at 04:28:11PM -0400, Jason Merrill wrote:
> > > On 10/11/22 16:00, Marek Polacek wrote:
> > > > Since r12-8066, in cxx_eval_vec_init we perform expand_vec_init_expr
> > > > while processing the default argument in this test.
> > > 
> > > Hmm, why are we calling cxx_eval_vec_init during parsing of the default
> > > argument?  In particular, any expansion that depends on the enclosing
> > > function context should be deferred until the default arg is used by a call.
> > 
> > I think this is part of the semantic constraints checking [dcl.fct.default]/5
> > talks about, as in, this doesn't compile even though the default argument is
> > not executed:
> > 
> > struct S {
> >    S() = delete;
> > };
> > void foo (S = S()) { }
> > In the test below we parse '= MyVector<1>()' and end up calling mark_used
> > on the implicit "constexpr MyVector<1>::MyVector() noexcept (<uninstantiated>)"
> > ctor.  mark_used calls maybe_instantiate_noexcept.  Since the ctor has
> > a DEFERRED_NOEXCEPT, we have to figure out if the ctor should be noexcept
> > or not using get_defaulted_eh_spec.  That means walking the members of
> > MyVector.  Thus we reach
> >    /* Core 1351: If the field has an NSDMI that could throw, the
> >       default constructor is noexcept(false).  */
> 
> Maybe we need a cp_unevaluated here?  The operand of noexcept should be
> unevaluated.

That wouldn't help since get_nsdmi specifically does "cp_evaluated ev;",
so...
 
> > and call get_nsdmi on 'data'.  There we digest its initializer which is {}.
> > massage_init_elt calls digest_init_r on the {} and produces
> >    TARGET_EXPR <D.2518, <<< Unknown tree: vec_init_expr
> >      D.2518
> >      {} >>>>
> > and the subsequent fold_non_dependent_init leads to cxx_eval_vec_init
> > -> expand_vec_init_expr.
> > 
> > I think this is all correct except that the fold_non_dependent_init is
> > somewhat questionable to me; do we really have to fold in order to say
> > if the NSDMI init can throw?  Sure, we need to digest the {}, maybe
> > the field's ctors can throw, but I don't know about the folding.
> 
> And we can check cp_unevaluated_operand to avoid the
> fold_non_dependent_init?

...we'd still fold.  I'm not sure if we want a LOOKUP_ flag that says
"we're just checking if we can throw, don't fold".

Marek


  reply	other threads:[~2022-10-12 17:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 20:00 [PATCH] " Marek Polacek
2022-10-11 20:28 ` Jason Merrill
2022-10-12 16:27   ` [PATCH v2] " Marek Polacek
2022-10-12 16:47     ` Jason Merrill
2022-10-12 17:12       ` Marek Polacek [this message]
2022-10-12 18:23         ` Marek Polacek
2022-10-13 13:58           ` Marek Polacek
2022-10-13 14:45             ` Jason Merrill
2022-10-13 14:44           ` 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=Y0b1mRBxzilqA/0n@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).