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 E32CE3858C33 for ; Wed, 19 Jul 2023 14:11:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E32CE3858C33 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=1689775899; 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: in-reply-to:in-reply-to:references:references; bh=RomrXGWF96riJNbkK3yv49pP3+EOoS40NkC2O2D9iHw=; b=CvNvKYcd1wABe6wg+tFoA7+eR8SpYKlsKn4VB13JWjWK2hPUFl9c9eiAXjqnH5J+mt4cLT sGnod4NLds0QwzRPmsOHqzdNI+5tcNYpottA+zolDVnufwjuAw6rM+qApdsh6WVvCkUB+S OCgml8cRqBP/6GQ7+//Gk6RvScnS3hk= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-ZburMb9pOY6BN-vuBmNsYw-1; Wed, 19 Jul 2023 10:11:29 -0400 X-MC-Unique: ZburMb9pOY6BN-vuBmNsYw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-765a44ce88aso69821785a.1 for ; Wed, 19 Jul 2023 07:11:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689775888; x=1692367888; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RomrXGWF96riJNbkK3yv49pP3+EOoS40NkC2O2D9iHw=; b=TZrQuV7VazVaiu0/zMMZD8ozretQLrJ/AzC/IX23AVGV5MwAigPfZPcvj84ZepEW8n VdgmjTII/1UWU/Tjo3eylWy5cMGJ+lXdBaZpjjTdmgMnxEWScqzxODO24dxAFEJQGloq y+h5Kq3KPzEVR+JAakc6OB3Ku9vnGnbVOVQE7MQnY+ffr8gMEh2Kif4t40IAmArou3nf IGn+IAbmkzPhU/Uv8FV5FPKZAXb7IRgIEJKYfd426GA0CCsIgpQQwxtGgVKzcQD7xyDr v/U86PdzEr7lQEhQNsQsA45HM324Z3qRlja/hjl9jKYIMfuUC4S+O9wva+mChVYsaLrj NmqQ== X-Gm-Message-State: ABy/qLbzzmMroVj8/6uCIFyH4aNmVqJvNG5gQHWvWUzvK90Q8Ss94Ler vhQBhBznBSF6ycf9B3YlfDhIosd3INyit9C/0VnKy1Kkvo7MFybzZazMp5lZjUEEkprm8HS/Ici mIdJZQlpVQGbrnJQxRA== X-Received: by 2002:a05:620a:1918:b0:767:c30:517 with SMTP id bj24-20020a05620a191800b007670c300517mr2695857qkb.3.1689775888621; Wed, 19 Jul 2023 07:11:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8QCDDbSl4H2FRn6DwW+veHjw7xv62yOgHJge+Nb8DNvdO6J+P39HZQvGKC1ysjvdwnlIR0g== X-Received: by 2002:a05:620a:1918:b0:767:c30:517 with SMTP id bj24-20020a05620a191800b007670c300517mr2695838qkb.3.1689775888354; Wed, 19 Jul 2023 07:11:28 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id cc23-20020a05622a411700b0040331a24f16sm1371172qtb.3.2023.07.19.07.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 07:11:27 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Wed, 19 Jul 2023 10:11:27 -0400 (EDT) To: Marek Polacek cc: GCC Patches , Jason Merrill Subject: Re: [PATCH] c++: fix ICE with is_really_empty_class [PR110106] In-Reply-To: <20230718211458.858343-1-polacek@redhat.com> Message-ID: <7007162f-c356-cbde-575e-1cbbd545323d@idea> References: <20230718211458.858343-1-polacek@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 List-Id: On Tue, 18 Jul 2023, Marek Polacek via Gcc-patches wrote: > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk and branches? Looks reasonable to me. Though I wonder if we could also fix this by not checking potentiality at all in this case? The problematic call to is_rvalue_constant_expression happens from cp_parser_constant_expression with 'allow_non_constant' != 0 and with 'non_constant_p' being a dummy out argument that comes from cp_parser_functional_cast, so the result of is_rvalue_constant_expression is effectively unused in this case, and we should be able to safely elide it when 'allow_non_constant && non_constant_p == nullptr'. Relatedly, ISTM the member cp_parser::non_integral_constant_expression_p is also effectively unused and could be removed? > > -- >8 -- > > is_really_empty_class is liable to crash when it gets an incomplete > or dependent type. Since r11-557, we pass the yet-uninstantiated > class type S<0> of the PARM_DECL s to is_really_empty_class -- because > of the potential_rvalue_constant_expression -> is_rvalue_constant_expression > change in cp_parser_constant_expression. Here we're not parsing > a template so we did not check COMPLETE_TYPE_P as we should. > > PR c++/110106 > > gcc/cp/ChangeLog: > > * constexpr.cc (potential_constant_expression_1): Check COMPLETE_TYPE_P > even when !processing_template_decl. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept80.C: New test. > --- > gcc/cp/constexpr.cc | 2 +- > gcc/testsuite/g++.dg/cpp0x/noexcept80.C | 12 ++++++++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept80.C > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > index 6e8f1c2b61e..1f59c5472fb 100644 > --- a/gcc/cp/constexpr.cc > +++ b/gcc/cp/constexpr.cc > @@ -9116,7 +9116,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > if (now && want_rval) > { > tree type = TREE_TYPE (t); > - if ((processing_template_decl && !COMPLETE_TYPE_P (type)) > + if (!COMPLETE_TYPE_P (type) > || dependent_type_p (type) > || is_really_empty_class (type, /*ignore_vptr*/false)) > /* An empty class has no data to read. */ > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept80.C b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C > new file mode 100644 > index 00000000000..3e90af747e2 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C > @@ -0,0 +1,12 @@ > +// PR c++/110106 > +// { dg-do compile { target c++11 } } > + > +template struct S > +{ > +}; > + > +struct G { > + G(S<0>); > +}; > + > +void y(S<0> s) noexcept(noexcept(G{s})); > > base-commit: fca089e8a47314a40ad93527ba9f9d0d374b3afb > -- > 2.41.0 > >