1 | // RUN: %clangxx_asan -O0 %s -o %t && %run %t |
2 | |
3 | // Function jumps over variable initialization making lifetime analysis |
4 | // ambiguous. Asan should ignore such variable and program must not fail. |
5 | |
6 | #include <stdlib.h> |
7 | |
8 | int *ptr; |
9 | |
10 | void f1(int cond) { |
11 | if (cond) |
12 | goto label; |
13 | int tmp; |
14 | |
15 | label: |
16 | ptr = &tmp; |
17 | *ptr = 5; |
18 | } |
19 | |
20 | void f2(int cond) { |
21 | switch (cond) { |
22 | case 1: { |
23 | ++cond; |
24 | int tmp; |
25 | ptr = &tmp; |
26 | exit(status: 0); |
27 | case 2: |
28 | ptr = &tmp; |
29 | *ptr = 5; |
30 | exit(status: 0); |
31 | } |
32 | } |
33 | } |
34 | |
35 | void f3(int cond) { |
36 | { |
37 | int tmp; |
38 | goto l2; |
39 | l1: |
40 | ptr = &tmp; |
41 | *ptr = 5; |
42 | |
43 | exit(status: 0); |
44 | } |
45 | l2: |
46 | goto l1; |
47 | } |
48 | |
49 | void use(int *x) { |
50 | static int c = 10; |
51 | if (--c == 0) |
52 | exit(status: 0); |
53 | (*x)++; |
54 | } |
55 | |
56 | void f4() { |
57 | { |
58 | int x; |
59 | l2: |
60 | use(x: &x); |
61 | goto l1; |
62 | } |
63 | l1: |
64 | goto l2; |
65 | } |
66 | |
67 | int main() { |
68 | f1(cond: 1); |
69 | f2(cond: 1); |
70 | f3(cond: 1); |
71 | f4(); |
72 | return 0; |
73 | } |
74 | |