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

            Bug ID: 84690
           Summary: std::is_invocable not working for ambiguous calls
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vince.rev at gmail dot com
  Target Milestone: ---

Consider the following code:
==================================================
// Preamble
#include <iostream>
#include <type_traits>

// A base class
template <class T>
struct base {void operator()(T){};};

// Two derived classes inheriting from the same base classes
template <class... T>
struct derived1: base<T>... {using base<T>::operator()...;};
template <class... T>
struct derived2: base<T>... {using base<T>::operator()...;};

// A class inheriting from both derived1 and derived2
template <class T0, class... T>
struct functor: derived1<T0>, derived2<T0, T...> {
    using derived1<T0>::operator();
    using derived2<T0, T...>::operator();
};

// Main function
int main() {
    std::cout << std::is_invocable_v<functor<int, float, char>, int> << "\n";
    std::cout << std::is_invocable_v<functor<int, float, char>, float> << "\n";
    std::cout << std::is_invocable_v<functor<int, float, char>, char> << "\n";
    return 0;
}
==================================================

The std::is_invocable type trait from the standard library fails to detect that
the first call in the main function is ambiguous. The program returns 1, 1, 1
instead of 0, 1, 1. This seems to be related to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84689 and to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80245.

Reply via email to