summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/pr65081.c
blob: a1123fd37a023b988124ac773f2e21f18094c790 (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
/* PR sanitizer/65081 */
/* { dg-do run } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } */
/* { dg-options "-fsanitize=object-size -fno-sanitize-recover=object-size" } */

struct S
{
  int a;
  char p[1];
};

struct S b;

struct S *
foo ()
{
  struct S *i = &b;
  return i + 1;
}

int
main (void)
{
  struct S *i = foo () - 1;
  i->a = 1;
}