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 71B54385735A for ; Wed, 23 Aug 2023 19:45:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71B54385735A 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=1692819937; 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=VoLRKnpy2jZ3DYL9J7Ibl0tKAvbeSx+pVVqOEEtMn+I=; b=IXeinCBU7XTYE3UMgPXPoaSuF6jn0NdWXjKoCH+j7QwR/3sSJunMj+WCtOtNi3GaYLn8eT 2ivkrRAgNz0KwwDAz4wzSyoj/eKGu4d22j/0VRQsX4pub/ajHZXRBNkqFxJQ2wlHSmbd9s W2QMh0BPt4b3GYpWLoV6zaOSRXhwFMI= 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_256_GCM_SHA384) id us-mta-434-dJaZ9PrZOwSN5GweipUH7A-1; Wed, 23 Aug 2023 15:45:35 -0400 X-MC-Unique: dJaZ9PrZOwSN5GweipUH7A-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-63cd05c0415so73899276d6.1 for ; Wed, 23 Aug 2023 12:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692819935; x=1693424735; 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=VoLRKnpy2jZ3DYL9J7Ibl0tKAvbeSx+pVVqOEEtMn+I=; b=g8P+mOzDxSZq1MAsLMIiH2jeej8sWbt+13riY9ibnk7fTcQ4X2bj0/OqGvMTRpZON/ LMC9csXGwYwQ6iNTfQNqMQhZ2easVUqBqVRDtnC62Ian5WBzGDwB0Xs1Y2TSeaw0AwP/ inRP5qM8iNfUBDmVa+QCLI4hdEhPrZvjk/RVVVQO1B8NjX4OIZOHvRf6m22UY7awHdpv MDCxj1m5H+zIS6FH9veZKgaTK0Ds5DzIXJEjv95iIKVUICJyEGpFWbXxwX1APtBXbzjE a6fLCRCc7THXEusZPlvwT4fYNE8Wq+h/nKX1ZGXzkeUIyvpinviyQLqSBe8ofhmFhP82 q1hg== X-Gm-Message-State: AOJu0Yzo00gjSiECFlMp5J/xOd5QAqTYd8XQKquIkgkl6pfIzRjKcFM4 u3oSxP7PW35JAt1fXTZXRMn7SrbDFzn3ESmJGiCLFFGw3yYOjDJGGvwLaRd3+GIxkWHkEN1n/0v J5VVDxFhUX64RFegeEg== X-Received: by 2002:a0c:dc92:0:b0:64f:518d:ac91 with SMTP id n18-20020a0cdc92000000b0064f518dac91mr6165609qvk.8.1692819935521; Wed, 23 Aug 2023 12:45:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL9UVlSNqCSQ0iVjY1t0OVC4a3R+obpgtOIxnRtyzdKcidBUX1TROH4n1oxwC7xGWVDwmr7A== X-Received: by 2002:a0c:dc92:0:b0:64f:518d:ac91 with SMTP id n18-20020a0cdc92000000b0064f518dac91mr6165588qvk.8.1692819935249; Wed, 23 Aug 2023 12:45:35 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id x15-20020a0ce24f000000b006263a9e7c63sm2683148qvl.104.2023.08.23.12.45.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Aug 2023 12:45:34 -0700 (PDT) Message-ID: <04bfb515-906c-21d3-311f-0a1c022e3b22@redhat.com> Date: Wed, 23 Aug 2023 15:45:32 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] c++: refine CWG 2369 satisfaction vs non-dep convs [PR99599] To: Patrick Palka , gcc-patches@gcc.gnu.org References: <20230822015139.1920183-1-ppalka@redhat.com> From: Jason Merrill In-Reply-To: <20230822015139.1920183-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=-7.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 8/21/23 21:51, Patrick Palka wrote: > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look like > a reasonable approach? I didn't observe any compile time/memory impact > of this change. > > -- >8 -- > > As described in detail in the PR, CWG 2369 has the surprising > consequence of introducing constraint recursion in seemingly valid and > innocent code. > > This patch attempts to fix this surpising behavior for the majority > of problematic use cases. Rather than checking satisfaction before > _all_ non-dependent conversions, as specified by the CWG issue, > this patch makes us first check "safe" non-dependent conversions, > then satisfaction, then followed by "unsafe" non-dependent conversions. > In this case, a conversion is "safe" if computing it is guaranteed > to not induce template instantiation. This patch heuristically > determines "safety" by checking for a constructor template or conversion > function template in the (class) parm or arg types respectively. > If neither type has such a member, then computing the conversion > should not induce instantiation (modulo satisfaction checking of > non-template constructor and conversion functions I suppose). > > + /* We're checking only non-instantiating conversions. > + A conversion may instantiate only if it's to/from a > + class type that has a constructor template/conversion > + function template. */ > + tree parm_nonref = non_reference (parm); > + tree type_nonref = non_reference (type); > + > + if (CLASS_TYPE_P (parm_nonref)) > + { > + if (!COMPLETE_TYPE_P (parm_nonref) > + && CLASSTYPE_TEMPLATE_INSTANTIATION (parm_nonref)) > + return unify_success (explain_p); > + > + tree ctors = get_class_binding (parm_nonref, > + complete_ctor_identifier); > + for (tree ctor : lkp_range (ctors)) > + if (TREE_CODE (ctor) == TEMPLATE_DECL) > + return unify_success (explain_p); Today we discussed maybe checking CLASSTYPE_NON_AGGREGATE? Also, instantiation can also happen when checking for conversion to a pointer or reference to base class. Jason