Message ID | 8bd23f97-092f-3b4e-7ec7-c8fc677572d1@gmail.com |
---|---|
State | New |
Headers | show |
Series | [committed] add test for PR 50476 | expand |
Index: gcc/testsuite/gcc.dg/uninit-pr50476.c =================================================================== --- gcc/testsuite/gcc.dg/uninit-pr50476.c (nonexistent) +++ gcc/testsuite/gcc.dg/uninit-pr50476.c (working copy) @@ -0,0 +1,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" }