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.129.124]) by sourceware.org (Postfix) with ESMTPS id 3A2F9385841F for ; Thu, 8 Feb 2024 22:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A2F9385841F 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 3A2F9385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707430860; cv=none; b=uEWMaGHE9JKYyz15RYM2lwOz5JcszRokGEKi39Fk58FdE7yqdq+VHiuLQU6x9/+YNdfXKZObFF42KyHX7t4svWIKup5Opjd0lIsFLdxUi7WwgIXUB/jiw/2wqUXq0ZBdawV0mYr1nzCxyd+OUx1COMc+cKBoA5Khyp6VTUfsezU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707430860; c=relaxed/simple; bh=neDBlz+w25wSr3a7ZbSnTcQq0E0x2mmWHkjPQqL8M+A=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=b+N1i+Uahvj0DyMaaGSG56gKdemkw4FhZcjfrBuArWT8FvtTA5/q3iO3a+cq1MPh+zghwNdQWEXnuHctIVKqZPypU8P9ZwfpRhCiOO8EIwDxZGvYslPvLfXCYJucVXOsvPcSmNoNkoNtgJHrPZeB58iOtZox/CFI6eAqPh9XKOY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707430852; 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=B17FEbWJvF3GGZDzE1KnYiAda/R5M0Mk8J/lDANPhlM=; b=Zi1rxHBSnT9a939rSAIhzIN5QkRpEx7lttAd7OdcerFZgmZ+RQyHSMZOWgYDqRF7c/ee+L fpnS7rZUwTcaSS3zw8aWW6/52yRoXmz4AnmQFKi16RMxXDkmBSb/aKfME0uV/dBraZJAwi hHAIXFHDjb6Fffv+J9s0G468brwO094= 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_256_GCM_SHA384) id us-mta-687-cwjG-4a5OVWDXBpw9nwpOQ-1; Thu, 08 Feb 2024 17:20:51 -0500 X-MC-Unique: cwjG-4a5OVWDXBpw9nwpOQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7816bea8d28so245547885a.0 for ; Thu, 08 Feb 2024 14:20:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707430851; x=1708035651; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B17FEbWJvF3GGZDzE1KnYiAda/R5M0Mk8J/lDANPhlM=; b=T9aD/d/m/z+a0U2YoY33dq20s1r7p01TLru43coBZyNDMWNQBkdu4Kuji5m+nbnBDE LA3Jh7/vn4uP8MIuNh7nytxISf4rvvmDXHp7i6zi32+jFJmiAi3bNKaJMqIIsPHY1NLI mN5a7Gy7yqEqooGnUpIS7WsFder528kaSl4mOXTQ26xFFqNAyz6Y2CVIIiiP4Lm6u3wM Swxv6GkGN+Xa0vhaGyLMxBRnZ5RtaxPjrXvJsm11128umrQ9VpG9zOAAgtLG7oqi1Ebk op/wwayl4RvA5B4HosDjEzk5v0vVboT63dwrLxfJR850o7xeNqFYvE9M1Ehs4n55DYUI k2SQ== X-Forwarded-Encrypted: i=1; AJvYcCUblvEC7B0po3cCfvzn1Vjxvwf5s5RYcXGofcCyT1pjaHW7xHHjK+DwXdXsnpAK2pLVqBtfVCrLI0/K2zZkevASofDi/aNv2Q== X-Gm-Message-State: AOJu0YzSDXGdNEkm7SfU5yCsfdwlSkViVSq+MXzOQwaJi2yBPEVKynHI 9RlJUvswSjoO7XYALTFNYHXjOQMRtlW1Z7mbhP92GzQBgXo7uikDfSDAJXx+i3ccy+7l9d34xKI mmNZJT/KDs16LJqsB62M6OHPwV1ctreo0czJZY2v133MuIEu2x/L+P2zHazz9wEc= X-Received: by 2002:a05:620a:13e7:b0:783:28ef:6d40 with SMTP id h7-20020a05620a13e700b0078328ef6d40mr49042qkl.38.1707430850944; Thu, 08 Feb 2024 14:20:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5GoGr8qUUHSj7BozDBq1FkYhOgSElPmNrD56AqslCEpJkVNO9Xy3P/gzuqYEBLavzsUcEiQ== X-Received: by 2002:a05:620a:13e7:b0:783:28ef:6d40 with SMTP id h7-20020a05620a13e700b0078328ef6d40mr49017qkl.38.1707430850656; Thu, 08 Feb 2024 14:20:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWRS29DBBMa95UDCJvksDud74veqf49KTgVAj3VAgx3g6RLTzPtUxfV7tohZWeKU0vvO55UNBSgMRKWdhn9wq2r5gJ1hW454Q== Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id v24-20020a05620a123800b007854018044bsm199871qkj.134.2024.02.08.14.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 14:20:50 -0800 (PST) Date: Thu, 8 Feb 2024 17:20:48 -0500 From: Marek Polacek To: Jason Merrill Cc: Patrick Palka , GCC Patches Subject: Re: [PATCH v2] c++: make build_throw SFINAE-friendly [PR98388] Message-ID: References: <20240208020601.479863-1-polacek@redhat.com> <4237f72c-7d85-b45c-36c6-7724acfca898@idea> <20f15673-d134-490f-9a5f-d580bfdb7e5f@redhat.com> MIME-Version: 1.0 In-Reply-To: <20f15673-d134-490f-9a5f-d580bfdb7e5f@redhat.com> User-Agent: Mutt/2.2.12 (2023-09-09) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 Thu, Feb 08, 2024 at 04:53:45PM -0500, Jason Merrill wrote: > On 2/8/24 11:51, Marek Polacek wrote: > > On Thu, Feb 08, 2024 at 08:49:28AM -0500, Patrick Palka wrote: > > > On Wed, 7 Feb 2024, Marek Polacek wrote: > > > > > > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > > > > > -- >8 -- > > > > Here the problem is that we give hard errors while substituting > > > > template parameters during overload resolution of is_throwable > > > > which has an invalid throw in decltype. > > > > > > > > The backtrace shows that fn_type_unification -> instantiate_template > > > > -> tsubst* passes complain=0 as expected, but build_throw doesn't > > > > have a complain parameter. So let's add one. Also remove a redundant > > > > local variable which I should have removed in my P2266 patch. > > > > > > > > But there's still something not quite clear to me. I claim that 'b' > > > > in the testcase should evaluate to false since the first overload ought > > > > to have been discarded. EDG 6.6 agrees, but clang++, msvc, and icx evaluate > > > > it to true. Who's right? > > I think it should be true since P1155, which we implement in C++20 mode and > above (or rather, we implement the sequel P2266); since then we implicitly > move from the function parameter. > > The patch looks good except that we should test this expected value. I could add #if __cplusplus >= 202002L static_assert (b, "move from the function parameter"); #else static_assert (!b, "no move from the function parameter"); #endif but that's going to fail for C++20 and above. I wonder if this is the second half of the problem in 113789? I could comment the first static_assert and add a FIXME if that sounds good? > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae69.C > > @@ -0,0 +1,16 @@ > > +// PR c++/98388 > > +// { dg-do compile { target c++11 } } > > + > > +struct moveonly { > > + moveonly() = default; > > + moveonly(moveonly&&) = default; > > +}; > > + > > +template > > +constexpr auto is_throwable(T t) -> decltype(throw t, true) { > > + return true; > > +} > > +template > > +constexpr bool is_throwable(...) { return false; } > > + > > +constexpr bool b = is_throwable(moveonly{}); Marek