From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: refine CWG 2369 satisfaction vs non-dep convs [PR99599]
Date: Wed, 23 Aug 2023 15:45:32 -0400 [thread overview]
Message-ID: <04bfb515-906c-21d3-311f-0a1c022e3b22@redhat.com> (raw)
In-Reply-To: <20230822015139.1920183-1-ppalka@redhat.com>
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
next prev parent reply other threads:[~2023-08-23 19:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 1:51 Patrick Palka
2023-08-23 19:45 ` Jason Merrill [this message]
2023-08-24 13:31 ` Patrick Palka
2023-08-28 22:58 ` Jason Merrill
2023-09-06 22:00 ` Patrick Palka
2023-09-06 22:09 ` Patrick Palka
2023-09-07 18:36 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=04bfb515-906c-21d3-311f-0a1c022e3b22@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).