blob: c3b7186e97ace5f2e8f41036f754530a348e02d5 [file] [log] [blame]
int *global_ptr;
static void __attribute__((noinline))
called_by_test_1 (void)
{
int i = 42;
global_ptr = &i;
}
int test_1 (void)
{
called_by_test_1 ();
return *global_ptr; /* { dg-warning "dereferencing pointer 'global_ptr' to within stale stack frame" } */
}
static void __attribute__((noinline))
called_by_test_2 (int **out)
{
int i = 42;
*out = &i;
}
int test_2 (void)
{
int *ptr;
called_by_test_2 (&ptr);
return *ptr; /* { dg-warning "dereferencing pointer 'ptr' to within stale stack frame" } */
}
static int __attribute__((noinline))
called_by_test_3 (int **out)
{
int i = 42;
*out = &i;
return i;
}
int test_3 (void)
{
int *lhs_ptr;
*lhs_ptr = called_by_test_3 (&lhs_ptr); /* { dg-warning "use of uninitialized value 'lhs_ptr'" } */
return *lhs_ptr;
}