public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc warn when pointers not checked non-null before de-referencing.
@ 2021-06-13 22:30 Jonny Grant
  2021-06-14  5:15 ` Xi Ruoyao
  2021-06-14 15:19 ` Martin Sebor
  0 siblings, 2 replies; 16+ messages in thread
From: Jonny Grant @ 2021-06-13 22:30 UTC (permalink / raw)
  To: gcc-help

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

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

end of thread, other threads:[~2021-07-19 18:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13 22:30 gcc warn when pointers not checked non-null before de-referencing Jonny Grant
2021-06-14  5:15 ` Xi Ruoyao
2021-06-16 13:01   ` Jonny Grant
2021-06-16 13:36     ` Xi Ruoyao
2021-07-03 15:36       ` Jonny Grant
2021-07-06 15:39         ` Xi Ruoyao
2021-07-19 18:20           ` Jonny Grant
2021-06-16 17:59     ` Segher Boessenkool
2021-06-17 20:44       ` Jonny Grant
2021-06-18  4:16         ` Xi Ruoyao
2021-07-03 14:14           ` Jonny Grant
2021-07-03 16:22             ` Segher Boessenkool
2021-07-06 10:33               ` Jonny Grant
2021-06-18  8:38         ` Liu Hao
2021-06-18 14:53         ` Segher Boessenkool
2021-06-14 15:19 ` Martin Sebor

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