http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56428
Bug #: 56428
Summary: [C++11] "is not a constant expression" when comparing
non-type template argument to nullptr
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
struct A { };
template<bool B>
struct Builder
{
static A build() { return A(); }
};
template<A (*F)()>
A f()
{
return Builder<F != nullptr>::build();
}
A g();
int main()
{
f< &g >(); // OK
f< nullptr >(); // OK
f< &f<nullptr> >(); // ERROR
}
a.cc: In instantiation of 'A f() [with A (* F)() = f<0u>]':
a.cc:22:20: required from here
a.cc:13:41: error: '(f<0u> != 0u)' is not a constant expression
return Builder<F != nullptr>::build();
^
a.cc:13:41: note: in template argument for type 'bool'