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

            Bug ID: 89564
           Summary: decltype resolution ignores SFINAE
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Simon.Richter at hogyros dot de
  Target Milestone: ---

Similar to #89563, but even more minimal:

#include <type_traits>

struct one {};

struct two
{
        two() { }
        two(one const &) { }
        operator one() const { return one{}; }
};

template<typename T>
auto operator+(T const &lhs, two const &rhs) -> typename
std::enable_if<!std::is_same<T, two>::value, decltype(rhs + lhs)>::type
{
        return rhs + lhs;
}

void test()
{
        one o;
        two t;
        auto a = o + t;
}

My expectation would be to get a diagnostic that no matching operator+ can be
found, both MSVC and icc do this. gcc goes into infinite recursion
instantiating the template.

Reply via email to