gcc/testsuite/gcc.dg/uninit-pr50476.c
raw| 1 | /* PR middle-end/50476 - Warn of pointer set to object whose lifetime is limited |
| 2 | { dg-do compile } |
| 3 | { dg-options "-O1 -Wall" } */ |
| 4 | |
| 5 | int *x = 0; |
| 6 | |
| 7 | void f (void) |
| 8 | { |
| 9 | int y = 1; |
| 10 | x = &y; // { dg-warning "\\\[-Wdangling-pointer" } |
| 11 | } |
| 12 | |
| 13 | int g (void) |
| 14 | { |
| 15 | f (); |
| 16 | |
| 17 | return *x; // { dg-warning "\\\[-Wuninitialized" } |
| 18 | } |