public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tabloid.adroit at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99963] [11 Regression] [concepts] template <concept> vs concept auto reports ambiguous overload
Date: Tue, 21 Jun 2022 21:21:27 +0000	[thread overview]
Message-ID: <bug-99963-4-zSQBVT1ZIH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99963-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2022-06-21 21:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 20:02 [Bug c++/99963] New: " ldalessandro at gmail dot com
2021-04-14 15:41 ` [Bug c++/99963] [11 Regression] " ppalka at gcc dot gnu.org
2021-04-14 19:12 ` jason at gcc dot gnu.org
2021-04-15 14:26 ` ldalessandro at gmail dot com
2022-06-21 21:21 ` tabloid.adroit at gmail dot com [this message]
2022-06-23 18:47 ` tabloid.adroit at gmail dot com

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=bug-99963-4-zSQBVT1ZIH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).