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 0A3353858D33 for ; Sat, 17 Feb 2024 10:07:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A3353858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A3353858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708164476; cv=none; b=N6OWNy13EV0dh5cdYRbRVlpeW8rWoyBE8gmacVbHzbWlf0Encm5a2Mar9W4TYD6lDq2UKBT0i0LcY2+4fUajk0T28vhQrcT2BRkWi5WV0quMHQcluZlYF7NzLd7Ox+PgCaJhic3qMx2wLujEiaS6cl7bCFYLjL3LJ89kUFI85xg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708164476; c=relaxed/simple; bh=6pcf1mXKPi4ZZTCP3G+QQTdV76UWotIE569oCvmNJz4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=qlxz26tFx1sPMzLZG7G5IBTuJeRMCB0CdQbnFxTDHAEADqLMeASDV9OqG5JikypEdUXGUxGqFecb3IIHD1V52nh2Bo0XbUv4QIYTpsARm9vIJrWiZecIv8ZxBUGb4ZKJOoXeEofFlPCkZgNA2lVqe4jOgWBZddL3x9ZfS2VJ7cU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708164470; 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=eKZfsSQapA3PI5ELz7F/glnjbnvzfsRMMmHbsmQFk3o=; b=d1R4nZtyyigbl3n9RORGSwvXIrdEoScMU77AZnxRhS2m/NMWfrVQGcFBV0utx5gdMQTpZr WzRVBDOX6AORL3yA0wuvlwVdqzodFHIhdsX4BxlePIjBPSKqTpdvbrwc3KUilkgFYAxz1J mN7mrWWNpc9C85ucU1ZXHZ4jPkj1eg0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-IUDe74dmO36LO70Aj8GDBQ-1; Sat, 17 Feb 2024 05:07:49 -0500 X-MC-Unique: IUDe74dmO36LO70Aj8GDBQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33d18931b4eso615190f8f.1 for ; Sat, 17 Feb 2024 02:07:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708164467; x=1708769267; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eKZfsSQapA3PI5ELz7F/glnjbnvzfsRMMmHbsmQFk3o=; b=Dw9uXI6UTLHeUvBJYHQSwgeSIVpqTCkk3/8c5WrjLK5DGd3sjfkSD7SLgLjb5ttRa1 vCmttgpQHdW13PxLiZqzubjmbsGXOS5q4w1lOeAWjk5kDF01jb/2wShdCa+qz1tEWySu rUeJXGJ3ObXIxifKjtnFKUxArdDKczWvQyj2adjgM+pbYTnL8JSW8mq6urc4n9fkh3/F 53bVr/M01ze6WGr9Le8AWK8tUiAVdlH9PwmP8k0x0dz3gBGrp4+5fe0zg10sGDd9XJ3Y Fs9rz9bua8xCmTJoPGA65LEko30PKCW0DC7W5YsQBTOx17qhMTCVrJheTfLVJO+Cwgjs iCZA== X-Gm-Message-State: AOJu0Yyr6xZp13y2M5pOVKZOBVAlQzm6B69ocp93d20Ami1CDoPJau6w tCFZ5+sZ94dJnPsE6cvcQNMdtqu4vmegfyzdMqh/7fJsqIqrzlvc7YLhoFfA5VMEG84RnCPvJQ/ gAFWEkhyv6FYfEEg+ov4e1SOVC0hUab7Inn7nxXErrvbWcDO/aBLDI2qoopdgsfK1jA== X-Received: by 2002:a05:6000:1286:b0:33d:3490:6e05 with SMTP id f6-20020a056000128600b0033d34906e05mr590462wrx.27.1708164467455; Sat, 17 Feb 2024 02:07:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAJxPPyG1UzhVV80JRH5Q+TNAI+eeImme6eQBxfjUqDph0cF/AQ85Jj2c5JTSwNmiPJJIUrg== X-Received: by 2002:a05:6000:1286:b0:33d:3490:6e05 with SMTP id f6-20020a056000128600b0033d34906e05mr590435wrx.27.1708164467052; Sat, 17 Feb 2024 02:07:47 -0800 (PST) Received: from ?IPV6:2a02:6b63:24c5:0:c6f7:d0f4:2019:ee02? ([2a02:6b63:24c5:0:c6f7:d0f4:2019:ee02]) by smtp.gmail.com with ESMTPSA id bx5-20020a5d5b05000000b0033d2432297fsm3107844wrb.88.2024.02.17.02.07.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 17 Feb 2024 02:07:45 -0800 (PST) Message-ID: Date: Sat, 17 Feb 2024 10:07:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] c++: wrong looser excep spec for dep noexcept [PR113158] To: Marek Polacek , Patrick Palka Cc: GCC Patches References: <20240215221742.646761-1-polacek@redhat.com> <6db4134a-3a48-4ed4-bbbf-914a4ea66f3d@redhat.com> <8dd4c839-0bf7-77e2-e2f9-3e60f391a6fb@idea> 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.0 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 2/16/24 17:06, Marek Polacek wrote: > On Fri, Feb 16, 2024 at 04:39:47PM -0500, Patrick Palka wrote: >> On Fri, 16 Feb 2024, Marek Polacek wrote: >>> + /* We also have to defer checking when we're in a template and couldn't >>> + instantiate & evaluate the noexcept to true/false. */ >>> + if (processing_template_decl) >>> + if ((base_throw >>> + && (base_throw != noexcept_true_spec >>> + || base_throw != noexcept_false_spec)) >> >> Shouldn't these innermost || be &&? > > D'oh, yes, what a dumb mistake. But that shows that we could also just > always return true in a template ;). > > Fixed. dg.exp passed so far. OK. > -- >8 -- > Here we find ourselves in maybe_check_overriding_exception_spec in > a template context where we can't instantiate a dependent noexcept. > That's OK, but we have to defer the checking otherwise we give wrong > errors. > > PR c++/113158 > > gcc/cp/ChangeLog: > > * search.cc (maybe_check_overriding_exception_spec): Defer checking > when a noexcept couldn't be instantiated & evaluated to false/true. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/noexcept83.C: New test. > --- > gcc/cp/search.cc | 11 ++++++++ > gcc/testsuite/g++.dg/cpp0x/noexcept83.C | 37 +++++++++++++++++++++++++ > 2 files changed, 48 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept83.C > > diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc > index c948839dc53..827f48e8604 100644 > --- a/gcc/cp/search.cc > +++ b/gcc/cp/search.cc > @@ -1975,6 +1975,17 @@ maybe_check_overriding_exception_spec (tree overrider, tree basefn) > || UNPARSED_NOEXCEPT_SPEC_P (over_throw)) > return true; > > + /* We also have to defer checking when we're in a template and couldn't > + instantiate & evaluate the noexcept to true/false. */ > + if (processing_template_decl) > + if ((base_throw > + && base_throw != noexcept_true_spec > + && base_throw != noexcept_false_spec) > + || (over_throw > + && over_throw != noexcept_true_spec > + && over_throw != noexcept_false_spec)) > + return true; > + > if (!comp_except_specs (base_throw, over_throw, ce_derived)) > { > auto_diagnostic_group d; > diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept83.C b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > new file mode 100644 > index 00000000000..47832bbb44d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept83.C > @@ -0,0 +1,37 @@ > +// PR c++/113158 > +// { dg-do compile { target c++11 } } > + > +template > +struct V { > + static constexpr bool t = false; > +}; > +struct base { > + virtual int f() = 0; > +}; > + > +template > +struct derived : base { > + int f() noexcept(V::t) override; > +}; > + > +struct base2 { > + virtual int f() noexcept = 0; > +}; > + > +template > +struct W { > + static constexpr bool t = B; > +}; > + > +template > +struct derived2 : base2 { > + int f() noexcept(W::t) override; // { dg-error "looser exception specification" } > +}; > + > +void > +g () > +{ > + derived d1; > + derived2 d2; // { dg-message "required from here" } > + derived2 d3; > +} > > base-commit: cd503b0616462445381a8232fb753239d319af76