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

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Unlike the false positive -Wuse-after-free in pr104232, the instance of
-Wdangling-pointer in this case (a PHI argument) is intentional so that we
diagnose problems like those in the request for it (pr63272), or in this more
involved test case:

void warn_cond_if (int i, int n)
{
  int *p;
  if (i)
    {
      int a[] = { 1, 2 };     // { dg-message "'a' declared" "note" }
      sink (a);
      p = a;
    }
  else
    p = (int*)malloc (n);

  sink (p);                   // { dg-warning "dangling pointer 'p' to 'a' may
be used" }
}

I could add another level to -Wdangling-pointer to separately control uses in
equality expressions, for consistency with -Wuse-after-free.

Reply via email to