aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-pr50476.c
blob: 37201841ad5e5b552099ed8ebe6a91e1be930c3a (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;       // { dg-warning "\\\[-Wdangling-pointer" }
}

int g (void)
{
  f ();

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