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

            Bug ID: 99963
           Summary: [concepts] template <concept> vs concept auto reports
                    ambiguous overload
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldalessandro at gmail dot com
  Target Milestone: ---

Consider the following code (https://godbolt.org/z/h1bz1qxan).

#include <concepts>

struct A{};
struct B : A {};

template <class T> 
concept is_a = std::is_base_of_v<A, T>;

template <class T>
concept is_b = is_a<T> and std::same_as<B, T>;

int foo(is_a auto, is_a auto);

#ifdef OK
int foo(is_b auto, is_a auto);
#else
template <is_a A>
int foo(is_b auto, A);
#endif

A a;
B b;
int d = foo(b, a);

<source>:23:12: error: call of overloaded 'foo(B&, A&)' is ambiguous
   23 | int d = foo(b, a);
      |         ~~~^~~~~~

With -DOK, which enables is_a auto syntax, this compiles. The template <is_a>
fails.

Reply via email to