summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/object-size-7.c
blob: 268de64df6ebe64f13de7b06e6c785d561a95a60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* { dg-do run } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
/* { dg-options "-fsanitize=object-size" } */

#define N 20

struct S { int a; };

__attribute__((noinline, noclone)) struct S
f1 (int i)
{
  struct S a[N];
  struct S *p = a;
  struct S s;
  s = p[i];
  return s;
}

int
main ()
{
  f1 (N);
  return 0;
}

/* { dg-output "load of address \[^\n\r]* with insufficient space for an object of type\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*note: pointer points here\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\[^\n\r]*(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*\\^" } */