https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71420
Bug ID: 71420
Summary: "‘type’ is not a class type" error for address-of
operator overloaded for enum type
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nekotekina at gmail dot com
Target Milestone: ---
I was not using gcc compiler directly (it happened for Travis build), sorry if
the information is misleading or inaccurate.
Code example (C++11):
namespace itype
{
enum type
{
unk = 0,
add,
sub,
//...
};
// Address-of operator for decoder<>
constexpr type operator &(type value)
{
return value;
}
}
// Irrelevant, only shows the meaning of the below template
struct interpreter
{
static void unk() { std::abort(); };
static void add();
static void sub();
//...
};
template<typename D, typename T = decltype(&D::unk)>
struct decoder
{
// Implementation omitted, low-relevant usage example:
static constexpr auto add = &D::add;
static constexpr auto sub = &D::sub;
};
decoder<interpreter> test1; // OK
decoder<itype::type> test2; // OK in Clang and MSVC
// Expected error: ‘itype::type’ is not a class type
int main()
{
return 0;
}