https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99963

tabloid.adroit at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tabloid.adroit at gmail dot com

--- Comment #4 from tabloid.adroit at gmail dot com ---
(In reply to Patrick Palka from comment #1)
> Started with r11-1571.  Reduced testcase that replaces the abbreviated
> function templates with their corresponding non-abbreviated forms:
> 
> template <class T> concept C1 = true;
> template <class T> concept C2 = C1<T> && true;
> 
> template <C1 T, C1 U> int f(T, U);
> template <C1 T, C2 U> int f(U, T);
> 
> int x = f(0, 0); // error: ambiguous call
> 
> 
> If I understand the wording of P2113 correctly:
> 
>   If deduction against the other template succeeds for both transformed
> templates, constraints can be considered as follows:
>   - ... if the corresponding template-parameters of the
> template-parameter-lists are not equivalent ([temp.over.link]) or if the
> function parameters that positionally correspond between the two templates
> are not of the same type, neither template is more specialized than the other
> 
> then I think we're correct to reject the call as ambiguous because although
> the second overload is more constrained than the first, their function
> parameter lists aren't equivalent.

IMHO, `template <C1 T, C2 U> int f(U, T);` should win over `template <C1 T, C1
U> int f(T, U);`.

Based on interpreting the intent mentioned in
https://github.com/cplusplus/nbballot/issues/119 and the second example in
https://eel.is/c++draft/temp.fct#temp.func.order-example-6, the `corresponding`
(of the `corresponding template-parameters of ...`) relationship is based on
the mapping used during partial-ordering deduction. So the deduction between
`f(T, ..)` against `f(U, ..)` builds the <T,U> mapping, the deduction between
`f(.., U)` against `f(.., T)` builds the <U, T> mapping. The correspondence is
[T, U] against [U, T]. So `C1 T` is less constrained than `C2 U`, thus the
second `f` wins.
  • [Bug c++/99963] [11 Regressio... tabloid.adroit at gmail dot com via Gcc-bugs

Reply via email to