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

            Bug ID: 86579
           Summary: invalid operands to binary expression
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The code is as follow:

template <typename T>
bool greater()
{
 T p = nullptr;
 return p > nullptr;
}

int main ()
{
 greater<void *>();
}

g++ accepts it, but clang++ reports a error message:

code0.cpp:5:11: error: invalid operands to binary expression ('void *' and
      'nullptr_t')
 return p > nullptr;
        ~ ^ ~~~~~~~
code0.cpp:10:2: note: in instantiation of function template specialization
      'greater<void *>' requested here
 greater<void *>();
 ^
1 error generated.

Reply via email to