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 34F643858D1E for ; Tue, 14 Feb 2023 22:00:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34F643858D1E 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=1676412002; 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=HH6YSNnx6p+7vV9zaGb8hd8+gnmIdi79tuQXyeb6fU8=; b=N4vpa32WPY4XvpRjx3ti+XpTMEqB8TSlfb5+WE29WbLhfU+3/afLpsfLoSB9RXIib8bWnV pf6OJosKmL7lSnw3yI3OwwqbIWkM+w2fRwmkK+eTW0zkaLZMayBoR5ynapSA5pPJHsRg9v Txex2Z4RifY0InAmMQIXqcqxNT3var0= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-310-TMBqYJLaOIGgMla4lXfNyA-1; Tue, 14 Feb 2023 17:00:01 -0500 X-MC-Unique: TMBqYJLaOIGgMla4lXfNyA-1 Received: by mail-qv1-f71.google.com with SMTP id jo26-20020a056214501a00b0053aa15f61d4so9496032qvb.7 for ; Tue, 14 Feb 2023 14:00:01 -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=HH6YSNnx6p+7vV9zaGb8hd8+gnmIdi79tuQXyeb6fU8=; b=Azy+xm2rhBA1kW4NyWVjMECnNPoQn7DYtpg5ms7fjrAykVAx6rwzQlVtCaeZIqSs7M /3XJlFBbLb2uIsSjm+3yoGgL686LyEfRUNMqlmvS4PjV/+jgfTqeibb3GK1kDHLx6jev YN6qBZa4+0FaxpxeXcJOlUC282MNll4j6S7QHqdeUIBgoH+ynSyEMM5VBuInJ882nSjz hYhhMkv+tLMMqYItypjM1hq4FeMAGCy0Rz39bTJqfVkW8M3Vt8QaNHS9Z/j3co1LnlrH 5vS8iphsCgO9rmKPOcOOLReKnMgNO4z5BUIys/ju1+Yw1iHqORFHrrgFDJrTvNmoy+rQ uKnw== X-Gm-Message-State: AO0yUKUOGQW3kW5YsSO3w9ntrpe01u0s7Be7ncxzH+4/eAVGbuAZy0Ht ChWYJ9xGC2OPz0V8d2BOhTt5XN0TwLCARcrhARuaADvrnYujGmZd9cAQ0t96EL8wPVjwhqxh9Uy gUPbRSj3LJgqmHqH3Sw== X-Received: by 2002:ac8:57c2:0:b0:3ba:38:2f5f with SMTP id w2-20020ac857c2000000b003ba00382f5fmr7155832qta.32.1676412000725; Tue, 14 Feb 2023 14:00:00 -0800 (PST) X-Google-Smtp-Source: AK7set+UQ4TTDj4vVQDNPlNdJ3wUSGHolhWb9Ow3ZtgCR5XepPh/C1I9rDt/QsDlf8eo7cOZt/HjlA== X-Received: by 2002:ac8:57c2:0:b0:3ba:38:2f5f with SMTP id w2-20020ac857c2000000b003ba00382f5fmr7155802qta.32.1676412000409; Tue, 14 Feb 2023 14:00:00 -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 78-20020a370a51000000b00706b09b16fasm12538113qkk.11.2023.02.14.13.59.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Feb 2023 13:59:59 -0800 (PST) Message-ID: <3aecc9c1-7488-1b12-6ce8-42513a3a9904@redhat.com> Date: Tue, 14 Feb 2023 16:59:59 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [PATCH] c++: fix ICE in joust_maybe_elide_copy [PR106675] To: Marek Polacek , GCC Patches References: <20230213170619.28996-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20230213170619.28996-1-polacek@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.6 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 2/13/23 09:06, Marek Polacek wrote: > joust_maybe_elide_copy checks that the last conversion in the ICS for > the first argument is ck_ref_bind, which is reasonable, because we've > checked that we're dealing with a copy/move constructor. But it can > also happen that we couldn't figure out which conversion function is > better to convert the argument, as in this testcase: joust couldn't > decide if we should go with > > operator foo &() > > or > > operator foo const &() > > so we get a ck_ambig, which then upsets joust_maybe_elide_copy. Since > a ck_ambig can validly occur, I think we should just return early, as > in the patch below. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/12? OK. > PR c++/106675 > > gcc/cp/ChangeLog: > > * call.cc (joust_maybe_elide_copy): Return false for ck_ambig. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/overload-conv-5.C: New test. > --- > gcc/cp/call.cc | 2 ++ > gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C | 21 ++++++++++++++++++++ > 2 files changed, 23 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C > > diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc > index a349d8e79db..048b2b052f8 100644 > --- a/gcc/cp/call.cc > +++ b/gcc/cp/call.cc > @@ -12542,6 +12542,8 @@ joust_maybe_elide_copy (z_candidate *&cand) > if (!DECL_COPY_CONSTRUCTOR_P (fn) && !DECL_MOVE_CONSTRUCTOR_P (fn)) > return false; > conversion *conv = cand->convs[0]; > + if (conv->kind == ck_ambig) > + return false; > gcc_checking_assert (conv->kind == ck_ref_bind); > conv = next_conversion (conv); > if (conv->kind == ck_user && !TYPE_REF_P (conv->type)) > diff --git a/gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C b/gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C > new file mode 100644 > index 00000000000..b1e7766e42b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/overload-conv-5.C > @@ -0,0 +1,21 @@ > +// PR c++/106675 > +// { dg-do compile { target c++11 } } > + > +struct foo { > + int n_; > + foo(int n) : n_(n) {} > +}; > + > +struct bar { > + int n_; > + > + operator foo() const { > + return foo(n_); > + } > + operator foo &() { return *reinterpret_cast(n_); } > + operator foo const &() = delete; > + > + void crashgcc() { > + foo tmp(*this); // { dg-error "ambiguous" } > + } > +}; > > base-commit: 72ae1e5635648bd3f6a5760ca46d531ad1f2c6b1