public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95589] New: missing warning initializing a reference with a dereferenced null
@ 2020-06-08 19:25 msebor at gcc dot gnu.org
  2020-06-08 19:29 ` [Bug c++/95589] " msebor at gcc dot gnu.org
  2021-08-13  8:13 ` egallager at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-06-08 19:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95589

            Bug ID: 95589
           Summary: missing warning initializing a reference with a
                    dereferenced null
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

Initializing a reference by dereferenced null pointer is not diagnosed but
should be because such a reference is invalid:

$ cat t.C && gcc -O2 -S -Wall -Wextra -Wnull-dereference
-fdump-tree-optimized=/dev/stdout t.C
void f (const int&);
void g ()
{
  int *p = 0;
  f (*p);
}

;; Function g (_Z1gv, funcdef_no=0, decl_uid=2330, cgraph_uid=1,
symbol_order=0)

g ()
{
  <bb 2> [local count: 1073741824]:
  f (0B); [tail call]
  return;

}

Clang doesn't diagnose it either unless --analyze is used:

$ clang -S -Wall -Wextra --analyze t.C
t.C:5:3: warning: Forming reference to null pointer
  f (*p);
  ^~~~~~
1 warning generated.

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

end of thread, other threads:[~2021-08-13  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 19:25 [Bug c++/95589] New: missing warning initializing a reference with a dereferenced null msebor at gcc dot gnu.org
2020-06-08 19:29 ` [Bug c++/95589] " msebor at gcc dot gnu.org
2021-08-13  8:13 ` egallager at gcc dot gnu.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).