public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/47931] New: missing -Waddress warning for comparison with NULL Date: Mon, 28 Feb 2011 19:43:00 -0000 [thread overview] Message-ID: <bug-47931-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47931 Summary: missing -Waddress warning for comparison with NULL Product: gcc Version: 4.4.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: msebor@gmail.com The -Waddress option causes gcc to emit a warning for suspicious tests of addresses of functions and objects. The patch that implemented the feature and the current test for it indicate that the diagnostic is intended to include the NULL pointer constant. However, gcc fails to diagnose the pointless comparison against NULL in the test case below. http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00972.html http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gcc.dg/Walways-true-1.c I note that Wstring-literal-comparison-1.c test exercises the ability to diagnose comparisons of string literals against 0 while at the same time allowing such comparisons against null pointer constant. Perhaps this feature conflicts with the ability to issue warnings for constants of other types. Alternatively, it's possible that the ability to avoid a diagnostic when a null pointer constant is used is deliberate. This is a request to either issue the warning in all cases, or to document the existing behavior so that it can be relied on with some assurance that it will continue to work this way in future versions of gcc. $ cat -n t.c && gcc -Waddress -c t.c 1 #define NULL (void*)0 2 3 int i; 4 5 int f() { return &i != 0; } 6 int g() { return &i != NULL; } t.c: In function ‘f’: t.c:5: warning: the address of ‘i’ will never be NULL
next reply other threads:[~2011-02-28 19:26 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-02-28 19:43 msebor at gmail dot com [this message] 2011-02-28 19:52 ` [Bug c/47931] " msebor at gmail dot com 2011-03-01 9:05 ` manu at gcc dot gnu.org 2011-03-01 10:16 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-47931-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).