This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86228] New: ordered comparison between pointer and zero
- From: "zhonghao at pku dot org.cn" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Jun 2018 03:01:23 +0000
- Subject: [Bug c++/86228] New: ordered comparison between pointer and zero
- Auto-submitted: auto-generated
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?