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

            Bug ID: 94563
           Summary: Relational operations between pointer and nullptr
                    accepted
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.kruegler at googlemail dot com
  Target Milestone: ---

The following code is accepted for language versions c++14, c++17, as well as
c++20 using the following additional compiler flags:

-Wall -Wextra -pedantic

bool test(int* p)
{
  return p < nullptr;
}

int main()
{
}

It should be noted, that a warning is emitted, satisfying the requirement for a
diagnostic in a strict sense:

>>>>>>>>>>>>>>
prog.cc: In function 'bool test(int*)':
prog.cc:3:12: warning: ordered comparison of pointer with integer zero
[-Wextra]
    3 |   return p < nullptr;
      |          ~~^~~~~~~~~

0
>>>>>>>>>>>>>>

This code should be ill-formed since the acceptance of

http://wg21.link/n3624

Reply via email to