gcc warn when pointers not checked non-null before de-referencing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

This isn't real code, just an example to show.

I've tried with:  -Wall -Wextra -O2  and some other warnings, but couldn't get this to generate a warning that *g was possibly de-referenced. May I ask, does GCC have a way to get warnings when pointers are not checked?
I had a look but -Wnull-dereference didn't help.

#include <stdlib.h>

#include <cstddef>
void f(int * g)
{
    *g = 1;

    if(NULL == g)
    {
        exit(1);
    }
}

Best regards Jonny



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux