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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
This should be easily detectable even without optimization by the new
-Wdangling-pointer.  I think it's essentially equivalent to the following test
case:

$ cat t.C && gcc -S -Wall -fdump-tree-waccess1=/dev/stdout t.C
struct A
{
  int &r;
};

A f ()
{
  int x = 0;
  return A{ x };
}

;; Function f (_Z1fv, funcdef_no=0, decl_uid=2373, cgraph_uid=1,
symbol_order=0)
...
struct A f ()
{
  int x;
  struct A D.2386;

  <bb 2> :
  x = 0;
  D.2386.r = &x;     <<< not handled by -Wdangling-pointer
  x ={v} {CLOBBER};

  <bb 3> :
<L1>:
  return D.2386;     <<<

}

Reply via email to