111
|
1 /* PR sanitizer/80998 */
|
|
2 /* { dg-do run } */
|
|
3 /* { dg-options "-fsanitize=pointer-overflow -fsanitize-recover=pointer-overflow -fno-ipa-icf -Wall" } */
|
|
4
|
|
5 __attribute__((noinline, noclone)) char * f1 (char *p) { return p + 1; }
|
|
6 __attribute__((noinline, noclone)) char * f2 (char *p) { return p - 1; }
|
|
7 __attribute__((noinline, noclone)) char * f3 (char *p, int i) { return p + i; }
|
|
8 __attribute__((noinline, noclone)) char * f4 (char *p, int i) { return p + i; }
|
|
9 __attribute__((noinline, noclone)) char * f5 (char *p, int i) { return p - i; }
|
|
10 __attribute__((noinline, noclone)) char * f6 (char *p, int i) { return p - i; }
|
|
11 __attribute__((noinline, noclone)) char * f7 (char *p, unsigned long int i) { return p + i; }
|
|
12 __attribute__((noinline, noclone)) char * f8 (char *p, unsigned long int i) { return p + i; }
|
|
13 __attribute__((noinline, noclone)) char * f9 (char *p, unsigned long int i) { return p - i; }
|
|
14 __attribute__((noinline, noclone)) char * f10 (char *p, unsigned long int i) { return p - i; }
|
|
15 struct S { int a; int b; int c[64]; };
|
|
16 __attribute__((noinline, noclone)) int *f11 (struct S *p) { return &p->a; }
|
|
17 __attribute__((noinline, noclone)) int *f12 (struct S *p) { return &p->b; }
|
|
18 __attribute__((noinline, noclone)) int *f13 (struct S *p) { return &p->c[64]; }
|
|
19 __attribute__((noinline, noclone)) int *f14 (struct S *p, int i) { return &p->c[i]; }
|
|
20 __attribute__((noinline, noclone)) int *f15 (struct S *p, int i) { return &p->c[i]; }
|
|
21 __attribute__((noinline, noclone)) int *f16 (struct S *p) { return &p->a; }
|
|
22 __attribute__((noinline, noclone)) int *f17 (struct S *p) { return &p->b; }
|
|
23 __attribute__((noinline, noclone)) int *f18 (struct S *p) { return &p->c[64]; }
|
|
24 __attribute__((noinline, noclone)) int *f19 (struct S *p, int i) { return &p->c[i]; }
|
|
25 __attribute__((noinline, noclone)) int *f20 (struct S *p, int i) { return &p->c[i]; }
|
|
26 __attribute__((noinline, noclone)) int *f21 (struct S *p) { return &p->a; }
|
|
27 __attribute__((noinline, noclone)) int *f22 (struct S *p) { return &p->b; }
|
|
28 __attribute__((noinline, noclone)) int *f23 (struct S *p) { return &p->c[64]; }
|
|
29 __attribute__((noinline, noclone)) int *f24 (struct S *p, int i) { return &p->c[i]; }
|
|
30 __attribute__((noinline, noclone)) int *f25 (struct S *p, int i) { return &p->c[i]; }
|
|
31
|
|
32 char *volatile p;
|
|
33 __UINTPTR_TYPE__ volatile u;
|
|
34 struct S *volatile q;
|
|
35 int *volatile r;
|
|
36
|
|
37 int
|
|
38 main ()
|
|
39 {
|
|
40 u = ~(__UINTPTR_TYPE__) 0;
|
|
41 p = (char *) u;
|
|
42 p = f1 (p);
|
|
43 u = 0;
|
|
44 p = (char *) u;
|
|
45 p = f2 (p);
|
|
46 u = -(__UINTPTR_TYPE__) 7;
|
|
47 p = (char *) u;
|
|
48 p = f3 (p, 7);
|
|
49 u = 3;
|
|
50 p = (char *) u;
|
|
51 p = f4 (p, -4);
|
|
52 u = 23;
|
|
53 p = (char *) u;
|
|
54 p = f5 (p, 27);
|
|
55 u = -(__UINTPTR_TYPE__) 15;
|
|
56 p = (char *) u;
|
|
57 p = f6 (p, -15);
|
|
58 u = -(__UINTPTR_TYPE__) 29;
|
|
59 p = (char *) u;
|
|
60 p = f7 (p, 31);
|
|
61 u = 23;
|
|
62 p = (char *) u;
|
|
63 p = f9 (p, 24);
|
|
64 if (sizeof (unsigned long) < sizeof (char *))
|
|
65 return 0;
|
|
66 u = 7;
|
|
67 p = (char *) u;
|
|
68 p = f8 (p, -8);
|
|
69 u = -(__UINTPTR_TYPE__) 25;
|
|
70 p = (char *) u;
|
|
71 p = f10 (p, -25);
|
|
72 u = ~(__UINTPTR_TYPE__) 0;
|
|
73 q = (struct S *) u;
|
|
74 r = f11 (q);
|
|
75 r = f12 (q);
|
|
76 r = f13 (q);
|
|
77 r = f14 (q, 0);
|
|
78 r = f15 (q, 63);
|
|
79 u = ~(__UINTPTR_TYPE__) 0 - (17 * sizeof (int));
|
|
80 q = (struct S *) u;
|
|
81 r = f16 (q);
|
|
82 r = f17 (q);
|
|
83 r = f18 (q);
|
|
84 r = f19 (q, 0);
|
|
85 r = f20 (q, 63);
|
|
86 u = 3 * sizeof (int);
|
|
87 q = (struct S *) u;
|
|
88 r = f21 (q);
|
|
89 r = f22 (q);
|
|
90 r = f23 (q);
|
|
91 r = f24 (q, -2);
|
|
92 r = f25 (q, -6);
|
|
93 return 0;
|
|
94 }
|
|
95
|
|
96 /* { dg-output ":5:6\[79]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+ overflowed to (0\[xX])?0\+(\n|\r\n|\r)" } */
|
|
97 /* { dg-output "\[^\n\r]*:6:6\[79]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+ overflowed to (0\[xX])?\[fF]\+(\n|\r\n|\r)" } */
|
|
98 /* { dg-output "\[^\n\r]*:7:7\[46]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+9 overflowed to (0\[xX])?0\+(\n|\r\n|\r)" } */
|
|
99 /* { dg-output "\[^\n\r]*:8:7\[46]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+3 overflowed to (0\[xX])?\[fF]\+(\n|\r\n|\r)" } */
|
|
100 /* { dg-output "\[^\n\r]*:9:7\[46]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+17 overflowed to (0\[xX])?\[fF]\+\[cC](\n|\r\n|\r)" } */
|
|
101 /* { dg-output "\[^\n\r]*:10:7\[46]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+1 overflowed to (0\[xX])?0\+(\n|\r\n|\r)" } */
|
|
102 /* { dg-output "\[^\n\r]*:11:\[89]\[80]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+\[eE]3 overflowed to (0\[xX])?0\+2(\n|\r\n|\r)" } */
|
|
103 /* { dg-output "\[^\n\r]*:13:\[89]\[80]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+17 overflowed to (0\[xX])?\[fF]\+(\n|\r\n|\r)" } */
|
|
104 /* { dg-output "\[^\n\r]*:12:\[89]\[80]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+7 overflowed to (0\[xX])?\[fF]\+(\n|\r\n|\r)" } */
|
|
105 /* { dg-output "\[^\n\r]*:14:\[89]\[91]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+\[eE]7 overflowed to (0\[xX])?0\+" } */
|
|
106 /* { dg-output "(\n|\r\n|\r)" { target int32 } } */
|
|
107 /* { dg-output "\[^\n\r]*:17:\[67]\[82]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+ overflowed to (0\[xX])?0\+3(\n|\r\n|\r)" { target int32 } } */
|
|
108 /* { dg-output "\[^\n\r]*:18:\[67]\[86]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+ overflowed to (0\[xX])?0\+107(\n|\r\n|\r)" { target int32 } } */
|
|
109 /* { dg-output "\[^\n\r]*:19:\[78]\[52]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+ overflowed to (0\[xX])?0\+7(\n|\r\n|\r)" { target int32 } } */
|
|
110 /* { dg-output "\[^\n\r]*:20:\[78]\[52]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+ overflowed to (0\[xX])?0\+103(\n|\r\n|\r)" { target int32 } } */
|
|
111 /* { dg-output "\[^\n\r]*:23:\[67]\[86]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+\[bB]\[bB] overflowed to (0\[xX])?0\+\[cC]3(\n|\r\n|\r)" { target int32 } } */
|
|
112 /* { dg-output "\[^\n\r]*:25:\[78]\[52]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?\[fF]\+\[bB]\[bB] overflowed to (0\[xX])?0\+\[bB]\[fF](\n|\r\n|\r)" { target int32 } } */
|
|
113 /* { dg-output "\[^\n\r]*:30:\[78]\[52]\[^\n\r]*runtime error: pointer index expression with base (0\[xX])?0\+\[cC] overflowed to (0\[xX])?\[fF]\+\[cC]" { target int32 } } */
|