From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] c++: P2448 - Relaxing some constexpr restrictions [PR106649]
Date: Fri, 18 Nov 2022 21:26:26 -0500 [thread overview]
Message-ID: <44e97804-e4d8-f1b4-8456-8577f2e5a8ab@redhat.com> (raw)
In-Reply-To: <8ce934d2-4775-2d27-6154-1b677dedc5a6@redhat.com>
On 11/16/22 15:27, Jason Merrill wrote:
> On 11/16/22 11:06, Marek Polacek wrote:
>> On Wed, Nov 16, 2022 at 08:41:53AM -0500, Jason Merrill wrote:
>>> On 11/15/22 19:30, Marek Polacek wrote:
>>>> @@ -996,19 +1040,26 @@ register_constexpr_fundef (const
>>>> constexpr_fundef &value)
>>>> **slot = value;
>>>> }
>>>> -/* FUN is a non-constexpr function called in a context that requires a
>>>> - constant expression. If it comes from a constexpr template,
>>>> explain why
>>>> - the instantiation isn't constexpr. */
>>>> +/* FUN is a non-constexpr (or, with -Wno-invalid-constexpr, a
>>>> constexpr
>>>> + function called in a context that requires a constant expression).
>>>> + If it comes from a constexpr template, explain why the
>>>> instantiation
>>>> + isn't constexpr. */
>>>
>>> The "if it comes from a constexpr template" wording has needed an
>>> update for
>>> a while now.
>>
>> Probably ever since r178519. I've added "Otherwise, explain why the
>> function
>> cannot be used in a constexpr context." Is that acceptable?
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/g++.dg/cpp23/constexpr-nonlit15.C
>>>> @@ -0,0 +1,43 @@
>>>> +// PR c++/106649
>>>> +// P2448 - Relaxing some constexpr restrictions
>>>> +// { dg-do compile { target c++23 } }
>>>> +// { dg-options "-Winvalid-constexpr" }
>>>> +// A copy/move assignment operator for a class X that is defaulted and
>>>> +// not defined as deleted is implicitly defined when it is odr-used,
>>>> +// when it is needed for constant evaluation, or when it is explicitly
>>>> +// defaulted after its first declaration.
>>>> +// The implicitly-defined copy/move assignment operator is constexpr.
>>>> +
>>>> +struct S {
>>>> + constexpr S() {}
>>>> + S& operator=(const S&) = default; // #1
>>>> + S& operator=(S&&) = default; // #2
>>>> +};
>>>> +
>>>> +struct U {
>>>> + constexpr U& operator=(const U&) = default;
>>>> + constexpr U& operator=(U&&) = default;
>>>> +};
>>>> +
>>>> +/* FIXME: If we only declare #1 and #2, and default them here:
>>>> +
>>>> + S& S::operator=(const S&) = default;
>>>> + S& S::operator=(S&&) = default;
>>>> +
>>>> +then they aren't constexpr. This sounds like a bug:
>>>> +<https://gcc.gnu.org/PR107598>. */
>>>
>>> As I commented on the PR, I don't think this is actually a bug, so let's
>>> omit this FIXME.
>>
>> I'm glad I didn't really attempt to "fix" it (the inform message is
>> flawed
>> and should be improved). Thanks for taking a look.
>>
>> Here's a version with the two comments updated.
>>
>> Ok?
>
> OK.
Since this patch I'm seeing these failures:
FAIL: g++.dg/cpp0x/constexpr-ex1.C -std=c++23 -fimplicit-constexpr at
line 91 (test for errors, line 89)
FAIL: g++.dg/cpp23/constexpr-nonlit10.C -std=gnu++23
-fimplicit-constexpr (test for warnings, line 14)
FAIL: g++.dg/cpp23/constexpr-nonlit10.C -std=gnu++23
-fimplicit-constexpr (test for warnings, line 20)
FAIL: g++.dg/cpp23/constexpr-nonlit11.C -std=gnu++23
-fimplicit-constexpr (test for warnings, line 28)
FAIL: g++.dg/cpp23/constexpr-nonlit11.C -std=gnu++23
-fimplicit-constexpr (test for warnings, line 31)
FAIL: g++.dg/cpp2a/spaceship-eq3.C -std=c++23 -fimplicit-constexpr
(test for excess errors)
Jason
next prev parent reply other threads:[~2022-11-19 2:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 20:53 [PATCH] " Marek Polacek
2022-11-14 23:00 ` Jason Merrill
2022-11-16 0:30 ` [PATCH v2] " Marek Polacek
2022-11-16 13:41 ` Jason Merrill
2022-11-16 16:06 ` [PATCH v3] " Marek Polacek
2022-11-16 20:27 ` Jason Merrill
2022-11-19 2:26 ` Jason Merrill [this message]
2022-12-02 19:48 ` Marek Polacek
2022-12-02 20:01 ` 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=44e97804-e4d8-f1b4-8456-8577f2e5a8ab@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--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).