From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
gcc-patches@gcc.gnu.org, Marek Polacek <polacek@redhat.com>
Subject: Re: [PATCH] c++, v2: Implement C++23 P2647R1 - Permitting static constexpr variables in constexpr functions
Date: Wed, 16 Nov 2022 15:26:32 -0500 [thread overview]
Message-ID: <d481192c-0033-a6e4-d339-6722901685b1@redhat.com> (raw)
In-Reply-To: <Y3T3tU4lD8GnOhE1@tucnak>
On 11/16/22 09:46, Jakub Jelinek wrote:
> On Wed, Nov 16, 2022 at 09:33:27AM -0500, Jason Merrill wrote:
>>> and at that point I fear decl_maybe_constant_var_p will not work
>>> properly. Shall this hunk be moved somewhere else (cp_finish_decl?)
>>> where we can already call it, or do the above in start_decl for
>>> cxx_dialect < cxx20 and add a cxx_dialect == cxx20 hunk in cp_finish_decl?
>>
>> Hmm, I'd expect decl_maybe_constant_var_p to work fine at this point.
>
> For static constexpr vars sure, but what about
> static const where start_decl doesn't know the initializer?
> Sure, decl_maybe_constant_var_p will not crash in that case, but
> it will return true even if the static const var doesn't have
> a constant initializer. Sure, we'd catch that later on when actually
> trying to constexpr evaluate the function and hitting there the
> spots added for C++23 in potential_constant_expression*/cxx_eval_*,
> but it would mean that we don't reject it when nothing calls the functions.
>
> I meant something like:
> constexpr int bar (int x) { if (x) throw 1; return 0; }
> constexpr int foo () { static const int a = bar (1); return 0; }
> with -std=c++20 IMHO shouldn't be accepted, while in C++23 it should.
I'd expect us to reject that in C++20 in potential_constant_expression,
but it's a fair point; it is awkward that P2242 wasn't also accepted as
a DR.
Moving the check from start_decl to cp_finish_decl makes sense to me.
Jason
next prev parent reply other threads:[~2022-11-16 20:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 17:07 [PATCH] c++: " Jakub Jelinek
2022-11-13 11:45 ` [PATCH] c++, v2: " Jakub Jelinek
2022-11-15 23:36 ` Jason Merrill
2022-11-15 23:50 ` Jakub Jelinek
2022-11-16 0:27 ` Jonathan Wakely
2022-11-16 6:19 ` Jakub Jelinek
2022-11-16 13:20 ` Jason Merrill
2022-11-16 14:08 ` Jakub Jelinek
2022-11-16 14:33 ` Jason Merrill
2022-11-16 14:46 ` Jakub Jelinek
2022-11-16 20:26 ` Jason Merrill [this message]
2022-11-17 9:13 ` [PATCH] c++, v3: " Jakub Jelinek
2022-11-17 14:42 ` Jason Merrill
2022-11-17 18:42 ` Jakub Jelinek
2022-11-17 20:42 ` [PATCH] c++, v4: " Jakub Jelinek
2022-11-18 0:15 ` Marek Polacek
2022-11-18 7:48 ` Jakub Jelinek
2022-11-18 15:03 ` Marek Polacek
2022-11-18 15:14 ` Jakub Jelinek
2022-11-18 16:24 ` Jason Merrill
2022-11-18 16:34 ` Jakub Jelinek
2022-11-18 16:52 ` Jason Merrill
2022-11-18 0:28 ` Jason Merrill
2022-11-18 9:10 ` [PATCH] c++, v5: " Jakub Jelinek
2022-11-16 0:26 ` [PATCH] c++, v2: " Jonathan Wakely
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=d481192c-0033-a6e4-d339-6722901685b1@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=jwakely@redhat.com \
--cc=polacek@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).