summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/asan/use-after-scope-5.c
blob: b53712daa34ae0b59cae3749afb7cc712f2b29c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// { dg-do run }
// { dg-shouldfail "asan" }

int *ptr;

__attribute__((always_inline))
inline static void
foo(int v)
{
  int values[10];
  for (unsigned i = 0; i < 10; i++)
    values[i] = v;

  ptr = &values[3];
}

int
main (int argc, char **argv)
{
  foo (argc);

  return *ptr;
}

// { dg-output "ERROR: AddressSanitizer: stack-use-after-scope on address.*(\n|\r\n|\r)" }
// { dg-output "READ of size 4 at.*" }
// { dg-output ".*'values' <== Memory access at offset \[0-9\]* is inside this variable.*" }