[Bug c++/56428] New: [C++11] "is not a constant expression" when comparing non-type template argument to nullptr

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 22 19:51:00 GMT 2013


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'



More information about the Gcc-bugs mailing list