$ cat ptr.cpp extern void* p; int main() { return ( p<0 ? 1 : 0 ); } $ g++ ptr.cpp -Wall -Wextra -O2 -S -fdump-tree-optimized int main() () { <bb 2>: return 0; } gcc manual: "The option -Wextra also prints warning messages for the following cases: · A pointer is compared against integer zero with <, <=, >, or >=." so, this looks like a missed-diagnostics.
It works with the C front-end but the C++ front-end fails to warn. Confirmed.
On it.
Author: paolo Date: Wed Sep 28 22:04:48 2011 New Revision: 179321 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179321 Log: /cp 2011-09-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/45278 * typeck.c (cp_build_binary_op): With -Wextra, warn for ordered comparison of pointer with zero. /testsuite 2011-09-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/45278 * g++.dg/warn/Wextra-3.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/Wextra-3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.7.0.