This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/86228] New: ordered comparison between pointer and zero


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

            Bug ID: 86228
           Summary: ordered comparison between pointer and zero
           Product: gcc
           Version: unknown
            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:

extern void* p;
int main() { return ( p<0 ? 1 : 0 ); }

clang++ rejects it with an error message:
error: ordered comparison between pointer and zero ('void *' and 'int')
    int main() { return ( p<0 ? 1 : 0 ); }

However, g++ accepts it without any warnings. 

Is this code ill-formed?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]