gcc warn when pointers not checked non-null before de-referencing.
Jonny Grant
jg@jguk.org
Sun Jun 13 22:30:42 GMT 2021
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
More information about the Gcc-help
mailing list