Bug 45278 - -Wextra doesn't warn about (pointer < 0 ).
Summary: -Wextra doesn't warn about (pointer < 0 ).
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: 4.7.0
Assignee: Paolo Carlini
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-08-13 16:25 UTC by Pawel Sikora
Modified: 2011-09-28 22:05 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.2, 4.2.2, 4.3.2, 4.6.0
Last reconfirmed: 2010-08-13 21:28:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2010-08-13 16:25:00 UTC
$ 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:
 &#183; A pointer is compared against integer zero with <, <=, >, or >=."


so, this looks like a missed-diagnostics.
Comment 1 Andrew Pinski 2010-08-13 21:28:22 UTC
It works with the C front-end but the C++ front-end fails to warn.

Confirmed.
Comment 2 Paolo Carlini 2011-09-28 20:40:03 UTC
On it.
Comment 3 paolo@gcc.gnu.org 2011-09-28 22:04:51 UTC
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
Comment 4 Paolo Carlini 2011-09-28 22:05:55 UTC
Fixed for 4.7.0.