Debian Codegraph @

gcc/testsuite/gcc.dg/ubsan/pr112709-1.c

raw
1 /* PR sanitizer/112709 */
2 /* { dg-do compile } */
3 /* { dg-options "-fsanitize=undefined -O2" } */
4
5 struct S { char c[1024]; };
6 int foo (int);
7
8 __attribute__((returns_twice, noipa)) struct S
9 bar (int x)
10 {
11 (void) x;
12 struct S s = {};
13 s.c[42] = 42;
14 return s;
15 }
16
17 void
18 baz (struct S *p)
19 {
20 foo (1);
21 *p = bar (0);
22 }
23
24 void
25 qux (int x, struct S *p)
26 {
27 if (x == 25)
28 x = foo (2);
29 else if (x == 42)
30 x = foo (foo (3));
31 *p = bar (x);
32 }
33
34 void
35 corge (int x, struct S *p)
36 {
37 void *q[] = { &&l1, &&l2, &&l3, &&l3 };
38 if (x == 25)
39 {
40 l1:
41 x = foo (2);
42 }
43 else if (x == 42)
44 {
45 l2:
46 x = foo (foo (3));
47 }
48 l3:
49 *p = bar (x);
50 if (x < 4)
51 goto *q[x & 3];
52 }
53
54 void
55 freddy (int x, struct S *p)
56 {
57 *p = bar (x);
58 ++p;
59 if (x == 25)
60 x = foo (2);
61 else if (x == 42)
62 x = foo (foo (3));
63 *p = bar (x);
64 }