[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    [Bug c/47931] missing -Waddress warning for comparison with NULL
From:       "msebor at gmail dot com" <gcc-bugzilla () gcc ! gnu ! org>
Date:       2011-02-28 19:38:17
Message-ID: bug-47931-4-k6CKjJfgMd () http ! gcc ! gnu ! org/bugzilla/
[Download RAW message or body]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47931

--- Comment #1 from Martin Sebor <msebor at gmail dot com> 2011-02-28 19:38:15 UTC ---
To add a suggested solution to my report: Since many (most?) comparisons will
be against NULL which can be defined as either 0 or (void*)0 I think it would
be best to diagnose both forms. To make it possible to easily silence the
warning I suggest not diagnosing cases of comparison against a null pointer
constant of the same type. I.e., like so:

  int i;

  if (&i);               // warning
  if (&i == 0);          // warning
  if (&i == (void*)0);   // warning
  if (&i == (int*)0);    // NO warning
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic