This is the mail archive of the
mailing list for the GCC project.
Question about -Wnonnull
- From: Fredrik Hederstierna <fredrik dot hederstierna at securitas-direct dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 9 Mar 2012 14:33:09 +0100
- Subject: Question about -Wnonnull
I'm testing __attribute__((nonnull)) and -Wnonnull.
It seems like it does warn before constant/vrp propagations.
Example code does not warn for first 2 calls to f(NULL),
but warns for last 2 calls to f(NULL).
Couldn't this checker be improved/extended to do checks also after some basic optimizations like constant propagation pass?
(This could improve possibilities for static code analysis in compile time.)
static void f(const char *s) __attribute__((nonnull(1)));
const char *p = NULL;
f(p); /* No warning? */
f(p = NULL); /* No warning? */
f((const char*)NULL); /* gives warning */
f(NULL); /* gives warning */
static void f(const char *s)
Thanks & Best Regards