public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "walles at mailblocks dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/18854] New: Want warning for potential NULL-dereferences Date: Mon, 06 Dec 2004 13:44:00 -0000 [thread overview] Message-ID: <20041206134454.18854.walles@mailblocks.com> (raw) 1 #include <stdlib.h> 2 int main(int argc, char *argv[]) { 3 volatile char *monkey = (char*)malloc(1234); 4 monkey[0] = '\0'; 5 return 0; 6 } Since malloc() on line 3 can return NULL, I'd like a warning on line 4. Likewise, if -Wnonnull is enabled, passing a potential NULL pointer to a function marked with the "nonnull" attribute should give me a warning as well. IMO, all function returning pointers should be considered to potentially return NULL, unless the opposite can be proved. A function attribute saying that some function will never return NULL might be useful, but I'll leave that up to the potential implementer to implement or not. As this warning can potentially trigger in a lot of places in otherwise working code, this warning should be optional and (at least to begin with) default to off. -- Summary: Want warning for potential NULL-dereferences Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: walles at mailblocks dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18854
next reply other threads:[~2004-12-06 13:44 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-12-06 13:44 walles at mailblocks dot com [this message] 2004-12-06 14:19 ` [Bug c/18854] " pinskia at gcc dot gnu dot 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=20041206134454.18854.walles@mailblocks.com \ --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).