Skip to content

[concepts] ambiguous overload accepted as valid #49308

Closed
@ldalessa

Description

@ldalessa
Bugzilla Link 49964
Version 11.0
OS All
CC @zygoloid

Extended Description

Clang accepts the following concept code that gcc considers ambiguous (reduced testcase due to Patrick Palka).

  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); // expect error: ambiguous call

Live: https://godbolt.org/z/6K93d1Ye4

I originally submitted this as a gcc bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99963) but Patrick and Jason Merrill determined that gcc's behavior is correct.

According to their reading of the standard (I don't have the background to make this statement), this call to f should be ambiguous because the matching between the template argument index and function argument index is different in its two declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions