summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-pr50476.c
blob: db4146db3146cfb4507eb3630f998a82a0b52b6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited
   { dg-do compile }
   { dg-options "-O1 -Wall" } */

int *x = 0;

void f (void)
{
  int y = 1;
  x = &y;
}

int g (void)
{
  f ();

  return *x;    // { dg-warning "\\\[-Wuninitialized" }
}