view gcc/testsuite/gcc.dg/asan/use-after-scope-5.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { 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' \\(line 10\\) <== Memory access at offset \[0-9\]* is inside this variable.*" }