summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ubsan/vptr-6.C
blob: 1c8f16702608ebfa36f58f87f89ed5d17bc04ca2 (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
30
31
// { dg-do compile }
// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
// { dg-options "-fsanitize=vptr -O2 -fdump-tree-optimized" }

struct S { virtual ~S (); int i; _Complex int j[5]; };

int
f1 (S *p)
{
  return p->i;
}

int
f2 (S *p)
{
  return *&p->i;
}

_Complex int *
f3 (S *p, S *q)
{
  return &p->j[q->i];
}

int
f4 (S &p, S &q)
{
  return __imag__ p.j[q.i];
}

// { dg-final { scan-tree-dump-times "__ubsan_handle_dynamic_type_cache_miss" 5 "optimized" } }