Fix broken MinGW build of gcc.c
[official-gcc.git] / gcc / testsuite / g++.dg / asan / use-after-scope-2.C
blob92a4bd13029058c70c0b9735762f8be96e7f00bc
1 // { dg-do run }
2 // { dg-shouldfail "asan" }
4 #include <stdio.h>
6 struct Test
8   Test ()
9     {
10       my_value = 0;
11     }
13   ~Test ()
14     {
15       fprintf (stderr, "Value: %d\n", *my_value);
16     }
18   void init (int *v)
19     {
20       my_value = v;
21     }
23   int *my_value;
26 int main(int argc, char **argv)
28   Test t;
30   {
31     int x = argc;
32     t.init(&x);
33   }
35   return 0;
38 // { dg-output "ERROR: AddressSanitizer: stack-use-after-scope on address.*(\n|\r\n|\r)" }
39 // { dg-output "READ of size 4 at.*" }
40 // { dg-output ".*'x' <== Memory access at offset \[0-9\]* is inside this variable.*" }