public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/18854] New: Want warning for potential NULL-dereferences
@ 2004-12-06 13:44 walles at mailblocks dot com
  2004-12-06 14:19 ` [Bug c/18854] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: walles at mailblocks dot com @ 2004-12-06 13:44 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/18854] Want warning for potential NULL-dereferences
  2004-12-06 13:44 [Bug c/18854] New: Want warning for potential NULL-dereferences walles at mailblocks dot com
@ 2004-12-06 14:19 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-06 14:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-06 14:19 -------


*** This bug has been marked as a duplicate of 16351 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |diagnostic
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-06 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06 13:44 [Bug c/18854] New: Want warning for potential NULL-dereferences walles at mailblocks dot com
2004-12-06 14:19 ` [Bug c/18854] " pinskia at gcc dot gnu dot org

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).