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 D836A3836E69 for ; Thu, 2 Jun 2022 20:38:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D836A3836E69 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-Q4z7cWHvPmWyYdctZLuY-A-1; Thu, 02 Jun 2022 16:38:24 -0400 X-MC-Unique: Q4z7cWHvPmWyYdctZLuY-A-1 Received: by mail-qk1-f200.google.com with SMTP id az40-20020a05620a172800b006a5faff65c8so4518767qkb.7 for ; Thu, 02 Jun 2022 13:38:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=J6F41stuohmkw5DQlFOZ+KUrE7wMefDU+x91Nub6Ye8=; b=5zaSelhCWCdroPAyB4Rr+uxtHCn80lS0y3iFMjfgg2bj/iOROZ9XIGrWrW5OdLTg/s Vea3fXT6MfegLGlsi79P5yahvjbyZE7vlZFN0EFGXrPSx7Qp0pvrwscIGVJkq8EOsfmx t/On4cQ0WijDygMdLtDPN/59SjudjbDZbVfJfJFayvOpKuU+ARCgUUh+vFJuUJvbyXkJ LO8/Aqdmq6ACa6Gd+MyuuX39+XmfruDHuqZln56oHAinPb7QEdG9ChuD2MeTzXhfmqNY Y08oUoVPAs+bXbBOz1HHJI7hKH78rLkJ7mI/atYHytaJR7y9q/IOLr52O5QC9r9Em0EZ fDng== X-Gm-Message-State: AOAM5332glyc1LN+tG0xHJ7TYOe9EzKPx2h60FnD+0PvTZRC/WaIfB1q Pgn3UycfKr78HFQ0HNurTIxINuanK15J+1/BowY4ILQ01n3Q65xwpwjdqvdCRByWGVb37NLeUI4 42i6kEbhfjYoaJMIJQw== X-Received: by 2002:a05:6214:5284:b0:444:10c8:ee59 with SMTP id kj4-20020a056214528400b0044410c8ee59mr4798879qvb.68.1654202303934; Thu, 02 Jun 2022 13:38:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIvXtxH7WNWGzLto+/6I2yU0Hea0Ohdwq4QqjJF7302cHEpMGvGnzKAZsI6Z7uOFJSbheN+g== X-Received: by 2002:a05:6214:5284:b0:444:10c8:ee59 with SMTP id kj4-20020a056214528400b0044410c8ee59mr4798866qvb.68.1654202303647; Thu, 02 Jun 2022 13:38:23 -0700 (PDT) Received: from [192.168.1.100] (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 bl17-20020a05620a1a9100b006a693056b0dsm760985qkb.94.2022.06.02.13.38.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jun 2022 13:38:22 -0700 (PDT) Message-ID: <6ba546bf-2a91-76df-914e-3c23964ead5d@redhat.com> Date: Thu, 2 Jun 2022 16:38:21 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] c++: ICE with template NEW_EXPR [PR105803] To: Marek Polacek Cc: Patrick Palka , GCC Patches References: <20220601224536.1553412-1-polacek@redhat.com> <68b3a5ff-698d-e680-6c94-b9aa5b7f3127@redhat.com> From: Jason Merrill In-Reply-To: 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: 7bit X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2022 20:38:27 -0000 On 6/2/22 16:33, Marek Polacek wrote: > On Thu, Jun 02, 2022 at 04:26:27PM -0400, Jason Merrill wrote: >> On 6/2/22 16:10, Marek Polacek wrote: >>> index 1346a1d4c10..2bbd8785627 100644 >>> --- a/gcc/cp/constexpr.cc >>> +++ b/gcc/cp/constexpr.cc >>> @@ -9039,10 +9039,18 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, >>> "before C++17"); >>> return false; >>> - case DYNAMIC_CAST_EXPR: >>> - case PSEUDO_DTOR_EXPR: >>> case NEW_EXPR: >>> case VEC_NEW_EXPR: >>> + if (cxx_dialect >= cxx20) >>> + /* In C++20, new-expressions are potentially constant. */ >>> + return true; >>> + else if (flags & tf_error) >>> + error_at (loc, "new-expression is not a constant expression " >>> + "before C++20"); >>> + return false; >>> + >>> + case DYNAMIC_CAST_EXPR: >>> + case PSEUDO_DTOR_EXPR: >>> case DELETE_EXPR: >>> case VEC_DELETE_EXPR: >> >> Delete, too. > > Duh. Fixed: OK, thanks. > From 2423f6548405185e256036df3d0ef3c13fd996c5 Mon Sep 17 00:00:00 2001 > From: Marek Polacek > Date: Thu, 2 Jun 2022 15:56:18 -0400 > Subject: [PATCH] c++: new-expression is potentially constant in C++20 > > ... so adjust p_c_e accordingly. > > gcc/cp/ChangeLog: > > * constexpr.cc (potential_constant_expression_1): Treat > {,VEC_}NEW_EXPR and {,VEC_}DELETE_EXPRas potentially constant in C++20. > --- > gcc/cp/constexpr.cc | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > index 1346a1d4c10..684238883dc 100644 > --- a/gcc/cp/constexpr.cc > +++ b/gcc/cp/constexpr.cc > @@ -9039,12 +9039,20 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > "before C++17"); > return false; > > - case DYNAMIC_CAST_EXPR: > - case PSEUDO_DTOR_EXPR: > case NEW_EXPR: > case VEC_NEW_EXPR: > case DELETE_EXPR: > case VEC_DELETE_EXPR: > + if (cxx_dialect >= cxx20) > + /* In C++20, new-expressions are potentially constant. */ > + return true; > + else if (flags & tf_error) > + error_at (loc, "new-expression is not a constant expression " > + "before C++20"); > + return false; > + > + case DYNAMIC_CAST_EXPR: > + case PSEUDO_DTOR_EXPR: > case THROW_EXPR: > case OMP_PARALLEL: > case OMP_TASK: > > base-commit: 7b98910406b5000a6429c188b0c6cc14e3140637