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 E30233858D1E for ; Tue, 29 Nov 2022 21:16:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E30233858D1E 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=1669756580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/mcYsCwBqKVxOgvJrNfqI+WniK0LQPwcZ/kafYsQps=; b=eKBamkIfLQkbh7nXJ00IUgxbtcdO/84NJGJrcl6aupEG93NQYzAJjZbS+hicwgpzCa+qKP XcTuEOeSOs/GnuEHi+gmKI8XdyCupITwmxCZv72RlEDHl4LZ+q3dQ0yY0oThJVFXSTNNGO 0FSUGJsUkelLCkSOxXb1II1U6KVQhWQ= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-653-lDdbx-CpMbixikYzt1bXlw-1; Tue, 29 Nov 2022 16:16:17 -0500 X-MC-Unique: lDdbx-CpMbixikYzt1bXlw-1 Received: by mail-qt1-f199.google.com with SMTP id y19-20020a05622a121300b003a526e0ff9bso23506607qtx.15 for ; Tue, 29 Nov 2022 13:16:17 -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:from:references: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=a/mcYsCwBqKVxOgvJrNfqI+WniK0LQPwcZ/kafYsQps=; b=Gxs1IHkdE7EhcObWXizlACyhp05zrZA6nFRFSpn/bpsFngBFzvJPA0YFRIspYH1ced dBTO2rMol8NSA+lsi4+cBTkP66E2pIe3bJ1Fr6JJg2mjDni0mDG2b+3GK3BEUlsRBFPt G7LqOfSgxeoLDPsU7pqMqhia0D+kLFxOeJuHBTB+8LBfXjVUYk9QQ3kK0ap0hNWAH/un sHuFdifVvbsYlIo8miQk77ffZJ+ygeXqn6ChYUI9psCHTV3jN8B3dsyqgWtOuQxFR6Xb P6R1TEW6kS3nNJ+Kh9JcCCtQf6HswEUNjEoPBF9IMlMeYQfzwge1kTwDuIfBjPZTsrzw Rr9Q== X-Gm-Message-State: ANoB5pmT30Dn8CHnvt0ipUWl4U75WCbWSwXdkkce5hJBG6sQmWXsJ6hD dZiFcwc4dJ42E7cz3PrHSanRvAe3SQ0fYJdhLYjxoNTVjE1y9OJVuBnWtwCTV2i0IrSfHid1wFZ TqVqYleWFmiOVckQHXA== X-Received: by 2002:a05:620a:1225:b0:6ed:28b:764d with SMTP id v5-20020a05620a122500b006ed028b764dmr52105195qkj.328.1669756577207; Tue, 29 Nov 2022 13:16:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf4q68K2NHpPJSl57ZWzfxjCX6Btkxxb8Dpmafcv4PGnr/PKCCJbsKWw2Gy/CUDJR0mtOV3jhg== X-Received: by 2002:a05:620a:1225:b0:6ed:28b:764d with SMTP id v5-20020a05620a122500b006ed028b764dmr52105175qkj.328.1669756576863; Tue, 29 Nov 2022 13:16:16 -0800 (PST) Received: from [192.168.1.108] (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 r62-20020a37a841000000b006ecfb2c86d3sm10986645qke.130.2022.11.29.13.16.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Nov 2022 13:16:16 -0800 (PST) Message-ID: <325ad7e5-d814-07c2-e819-34c089fe19c5@redhat.com> Date: Tue, 29 Nov 2022 16:16:15 -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] c++: ICE with <=> of incompatible pointers [PR107542] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20221129200322.1544250-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20221129200322.1544250-1-ppalka@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: 7bit X-Spam-Status: No, score=-12.5 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,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/29/22 15:03, Patrick Palka wrote: > In a SFINAE context composite_pointer_type returns error_mark_node if > the given pointer types are incompatible, but the SPACESHIP_EXPR case of > cp_build_binary_op wasn't prepared to handle error_mark_node, which led > to an ICE (from spaceship_comp_cat) for the below testcase where we form > a <=> with incompatible pointer operands. > > (In a non-SFINAE context composite_pointer_type issues a permerror and > returns cv void* in this case, so no ICE.) > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/12? OK. > PR c++/107542 > > gcc/cp/ChangeLog: > > * typeck.cc (cp_build_binary_op): Handle result_type being > error_mark_node in the SPACESHIP_EXPR case. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp2a/spaceship-sfinae2.C: New test. > --- > gcc/cp/typeck.cc | 5 ++-- > .../g++.dg/cpp2a/spaceship-sfinae2.C | 29 +++++++++++++++++++ > 2 files changed, 32 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae2.C > > diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc > index f0e7452f3a0..10b7ed020f7 100644 > --- a/gcc/cp/typeck.cc > +++ b/gcc/cp/typeck.cc > @@ -6215,8 +6215,9 @@ cp_build_binary_op (const op_location_t &location, > tree_code orig_code0 = TREE_CODE (orig_type0); > tree orig_type1 = TREE_TYPE (orig_op1); > tree_code orig_code1 = TREE_CODE (orig_type1); > - if (!result_type) > - /* Nope. */; > + if (!result_type || result_type == error_mark_node) > + /* Nope. */ > + result_type = NULL_TREE; > else if ((orig_code0 == BOOLEAN_TYPE) != (orig_code1 == BOOLEAN_TYPE)) > /* "If one of the operands is of type bool and the other is not, the > program is ill-formed." */ > diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae2.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae2.C > new file mode 100644 > index 00000000000..52ff038b36f > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-sfinae2.C > @@ -0,0 +1,29 @@ > +// PR c++/107542 > +// { dg-do compile { target c++20 } } > + > +#include > + > +template > +concept same_as = __is_same(T, U); > + > +template > +concept Ord = requires(const Lhs& lhs, const Rhs& rhs) { > + { lhs <=> rhs } -> same_as; > +}; > + > +static_assert(Ord); // Works. > +static_assert(!Ord); // ICE. > + > +template > +struct S { > + T* p; > +}; > + > +template > + requires(Ord) > +constexpr inline auto operator<=>(const S& l, const S& r) noexcept { > + return l.p <=> r.p; > +} > + > +static_assert(Ord, S>); // Works. > +static_assert(!Ord, S>); // ICE.