public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: unsynthesized defaulted constexpr fn [PR110122]
Date: Wed, 7 Jun 2023 17:00:41 -0400	[thread overview]
Message-ID: <08e1b0b9-e2bd-1fb0-30a4-4ef3397631bc@redhat.com> (raw)
In-Reply-To: <20230606182953.815966-1-ppalka@redhat.com>

On 6/6/23 14:29, Patrick Palka wrote:
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?
> 
> -- >8 --
> 
> In the second testcase of PR110122, during regeneration of the generic
> lambda with V=Bar{}, substitution followed by coerce_template_parms for
> A<V>'s template argument naturally yields a copy of V in terms of Bar's
> (implicitly) defaulted copy constructor.
> 
> This however happens inside a template context so although we introduced
> a use of the copy constructor, mark_used didn't actually synthesize it,
> which causes subsequent constant evaluation of the template argument to
> fail with:
> 
>    nontype-class58.C: In instantiation of ‘void f() [with Bar V = Bar{Foo()}]’:
>    nontype-class58.C:22:11:   required from here
>    nontype-class58.C:18:18: error: ‘constexpr Bar::Bar(const Bar&)’ used before its definition
> 
> Conveniently we already make sure to instantiate eligible constexpr
> functions before such (manifestly) constant evaluation, as per P0859R0.
> So this patch fixes this by making sure to synthesize eligible defaulted
> constexpr functions beforehand as well.

We probably also want to do this in cxx_eval_call_expression, under

>   /* We can't defer instantiating the function any longer.  */

Jason


  reply	other threads:[~2023-06-07 21:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-06 18:29 Patrick Palka
2023-06-07 21:00 ` Jason Merrill [this message]
2023-06-08 19:54   ` Patrick Palka
2023-06-08 23:50     ` 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=08e1b0b9-e2bd-1fb0-30a4-4ef3397631bc@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@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).