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

            Bug ID: 90846
           Summary: Concepts sometimes ignored for friend function
                    templates of class templates
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at doublewise dot net
  Target Milestone: ---

The following code reports ambiguous overload when compiling with `g++
-std=c++2a -fconcepts`:



template<typename>
struct S {
    template<typename T>
    friend constexpr auto f(S, S<T>) {
        return true;
    }

    template<typename T> requires false
    friend constexpr auto f(S, T) {
        return false;
    }

    template<typename T> requires false
    friend constexpr auto f(T, S) {
        return false;
    }
};

static_assert(f(S<int>{}, S<int>{}));



It complains that all three functions are viable overloads. Deleting the second
overload makes gcc complain the that two remaining functions are ambiguous, but
deleting the third overload makes gcc happy and accept the code.

See it live: https://godbolt.org/z/wG3Isj

Reply via email to