From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1ACC1385223B for ; Sat, 19 Nov 2022 02:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1ACC1385223B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668824795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sp2PP5gLAvbbyLWqgtwMVQjJnExplP5eX+c2xgSYGW8=; b=LOIx1qoRlIM5xxjppBQpX+u84OESSWWHwZuihqX+C3uyuSw54sIyaXO2d248OXtoQcJ+OK dNuCsE/wO2eF5EVFhhwHk6/5PyKgI/O7C2JiuTAzyT38ZOTzFsb+ZeORq9UiUnwHnhQQvj XYqTgBkMDAqGmTWr7YdKEE6gGbZfhCE= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-518-5JIWM2z-OjGclLMfx6HpQA-1; Fri, 18 Nov 2022 21:26:34 -0500 X-MC-Unique: 5JIWM2z-OjGclLMfx6HpQA-1 Received: by mail-qk1-f197.google.com with SMTP id bq13-20020a05620a468d00b006fa5a75759aso8572719qkb.13 for ; Fri, 18 Nov 2022 18:26:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sp2PP5gLAvbbyLWqgtwMVQjJnExplP5eX+c2xgSYGW8=; b=gV+Dwhb8HQtTQ1xZrCEuXY/tHN/348q2+nBtfdfCTV5v8hYHuvtHcvPejuPecxboZP lpCm19vMTWGq1byo3Jn+kduXS3mR2aas+XAtO6w9SKlDPXWni/gpKy7YBRzfc/mr0PEz cXWHc+AFn8N3cAsr4OxJ2NE1rMFLv3cWd/CRndct1p+HA/+rtQscSVQsHycIHaoPi6wa DJurneRBSm2JO121e5B06X4NUTHna12C6czMLg7E1B2UqLjvNW3mhHWdGmc54vjV7TeO 08FyUNQ9h0juEWpTBLDlYZNDZJNX0Haf4MdpGLK7+uICdS6JHs9vDoodmMd4h/E+B1Db g/QA== X-Gm-Message-State: ANoB5pkQZWIdS+L+R4dgOru0erMdQywn54RZUbdQ2OSMODA3UMh34Mka KGQCG5cHTNDkN4mn3ITC/q+XkioQnq0fYjEmz8Fpc35UXuJTxM038qfHWYo72pblK6qXnL5oKzO d1t1+o1bXaxg9lFIBgA== X-Received: by 2002:a37:a8cd:0:b0:6fa:996d:730e with SMTP id r196-20020a37a8cd000000b006fa996d730emr8266165qke.723.1668824793953; Fri, 18 Nov 2022 18:26:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7SPb7jf0dHQ80H9wHJhecsLyad3onhJoNIvH36FG+S22GnfOM1fLeJhJOqEYHCC50Ge9e2xw== X-Received: by 2002:a37:a8cd:0:b0:6fa:996d:730e with SMTP id r196-20020a37a8cd000000b006fa996d730emr8266155qke.723.1668824793633; Fri, 18 Nov 2022 18:26:33 -0800 (PST) Received: from [192.168.1.137] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id i5-20020a05620a404500b006fb11eee465sm3628532qko.64.2022.11.18.18.26.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Nov 2022 18:26:32 -0800 (PST) Message-ID: <44e97804-e4d8-f1b4-8456-8577f2e5a8ab@redhat.com> Date: Fri, 18 Nov 2022 21:26:26 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v3] c++: P2448 - Relaxing some constexpr restrictions [PR106649] From: Jason Merrill To: Marek Polacek Cc: GCC Patches References: <20221109205305.96262-1-polacek@redhat.com> <5cfabd39-8afe-931c-7872-1b4360d2e5b5@redhat.com> <8ce934d2-4775-2d27-6154-1b677dedc5a6@redhat.com> In-Reply-To: <8ce934d2-4775-2d27-6154-1b677dedc5a6@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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: >>>> +.  */ >>> >>> 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