Disable gnat.dg/socket1.adb on hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / object-size-3.c
bloba88081c02a99e3501b2e18e0ee995ef4ca22dc20
1 /* { dg-do run } */
2 /* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
3 /* { dg-options "-fsanitize=object-size -fno-sanitize-recover=object-size" } */
5 /* Test valid uses. */
7 #define N 20
9 __attribute__((noinline, noclone)) void
10 f1 (int i)
12 volatile int j;
13 char *p, *orig;
14 orig = p = (char *) __builtin_calloc (N, 1);
15 j = *(p + i);
16 j = p[i];
17 p++;
18 j = p[i - 1];
19 j = *(p + i - 1);
20 __builtin_free (orig);
23 __attribute__((noinline, noclone)) void
24 f2 (int i)
26 volatile int j;
27 char a[N];
28 __builtin_memset (a, 0, N);
29 j = *(a + i);
30 char *p = a;
31 j = *(p + i);
32 j = p[i];
33 p += 10;
34 j = *(p + i - 10);
35 j = p[i - 10];
38 __attribute__((noinline, noclone)) void
39 f3 (int i)
41 volatile int j;
42 int *p = (int *) __builtin_calloc (N, sizeof (*p));
43 int *o = &p[i];
44 j = *o;
45 j = o[0];
46 __builtin_free (p);
49 int
50 main ()
52 f1 (N - 1);
53 f2 (N - 1);
54 f3 (N - 1);
55 return 0;