forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunion_etc.cpp
More file actions
43 lines (37 loc) · 715 Bytes
/
Copy pathunion_etc.cpp
File metadata and controls
43 lines (37 loc) · 715 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
struct S {
union U { int a, b; } u;
class C { public: int b, c; } c;
int x, d;
virtual void set_q(int val) { x = val; }
} s;
class C {
public:
struct S { int d, e; } s;
union U { int e, f; } u;
int f, g;
} c;
union U {
struct S { int g, h; } s;
class C { public: int h, i; } c;
int i, j;
} u;
int foo(void) {
S s;
C c;
U u;
s.u.a = c.s.e = u.c.i = 43;
s.u.b += (u.c.i + u.j);
return c.g;
}
struct T: S {
int q, r;
virtual void set_q(int val) { q = val; }
};
int bar(void) {
const T *s = (const T *)&c;
const S *t = static_cast<const S *>(s);
T *x = const_cast<T *>(s);
const T *v = dynamic_cast<const T *>(t);
S *w = reinterpret_cast<S *>(&c);
return x->c.b;
}