[Bug c++/90769] New: Template instantiation recursion when trying to do a conversion template
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 6 02:33:00 GMT 2019
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!=.
More information about the Gcc-bugs
mailing list