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

            Bug ID: 90769
           Summary: Template instantiation recursion when trying to do a
                    conversion template
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Reduced slightly from https://stackoverflow.com/q/56470126/2069064:

#include <type_traits>

enum E {A, B};

template<typename T, E e>
struct X
{
  template<E f = e, std::enable_if_t<(f == B), int> = 0>
  constexpr X(float v);

  template <typename OUT, E f = e, std::enable_if_t<(f == B), int> = 0>
  operator OUT() const;
};

#ifdef WORKS
bool operator!=(X<float, B> const& lhs, int) { 
    return static_cast<float>(lhs) == 0;
}
#else
bool operator==(X<float, B> const& lhs, int) { 
    return static_cast<float>(lhs) == 0;
}
#endif

Compiling with g++ 9.1 -std=c++17, with -DWORKS this compiles fine. Without it,
it fails due to reaching the max template instantiation limit. The only
difference between the two cases is that one is declaring an operator== and the
other is declaring an operator!=.

Reply via email to