Commit 586b016c by Jason Merrill

c++: Fix constrained conversion op.

We don't want to promote a conversion from viable == 0 to viable == -1.
Found in ranges-v3.

gcc/cp/ChangeLog
2020-02-28  Jason Merrill  <jason@redhat.com>

	* call.c (build_user_type_conversion_1): Don't look at the second
	conversion of a non-viable candidate.
parent 4735f92d
2020-02-28 Jason Merrill <jason@redhat.com>
* call.c (build_user_type_conversion_1): Don't look at the second
conversion of a non-viable candidate.
2020-02-28 Jakub Jelinek <jakub@redhat.com> 2020-02-28 Jakub Jelinek <jakub@redhat.com>
P1937R2 - Fixing inconsistencies between const{expr,eval} functions P1937R2 - Fixing inconsistencies between const{expr,eval} functions
......
...@@ -4083,6 +4083,10 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, ...@@ -4083,6 +4083,10 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
for (cand = candidates; cand != old_candidates; cand = cand->next) for (cand = candidates; cand != old_candidates; cand = cand->next)
{ {
if (cand->viable == 0)
/* Already rejected, don't change to -1. */
continue;
tree rettype = TREE_TYPE (TREE_TYPE (cand->fn)); tree rettype = TREE_TYPE (TREE_TYPE (cand->fn));
conversion *ics conversion *ics
= implicit_conversion (totype, = implicit_conversion (totype,
......
// { dg-do compile { target concepts } }
template <class T> concept False = false;
template <class T>
struct A
{
explicit operator bool ();
explicit operator bool () requires False<T>;
};
int main()
{
int i { A<int>() }; // { dg-error "" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment