From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28072 invoked by alias); 22 May 2008 09:05:35 -0000 Received: (qmail 27877 invoked by uid 48); 22 May 2008 09:04:51 -0000 Date: Thu, 22 May 2008 09:05:00 -0000 Subject: [Bug c/36299] New: spurious and undocumented warning with -Waddress for a == 0 when a is an array X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "vincent at vinc17 dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-05/txt/msg01689.txt.bz2 With -Waddress (implied by -Wall), I get the following warning when I use the test a == 0 where a is an array: the address of 'a' will never be NULL. This behavior is undocumented and inconsistent (see below). Here's a testcase: int main (void) { char a[1], *b; b = a; if (a == 0) return 1; else if (a == (void *) 0) return 2; else if (b == 0) return 3; else if (b == (void *) 0) return 4; return 0; } gcc warns only for a == 0 (and this is OK to use 0 instead of (void *) 0 because it is a valid form for a null pointer constant). Moreover this is very similar to code like if (1) ... or code given in bug 12963, for which gcc no longer emits warnings: indeed such kind of correct and useful code is typically used in macros. -- Summary: spurious and undocumented warning with -Waddress for a == 0 when a is an array Product: gcc Version: 4.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vincent at vinc17 dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299