1// RUN: %clangxx_cfi -o %t %s
2// RUN: %run %t
3
4// In this example, both __typeid_A_global_addr and __typeid_B_global_addr will
5// refer to the same address. Make sure that the compiler does not assume that
6// they do not alias.
7
8struct A {
9 virtual void f() = 0;
10};
11
12struct B : A {
13 virtual void f() {}
14};
15
16__attribute__((weak)) void foo(void *p) {
17 B *b = (B *)p;
18 A *a = (A *)b;
19 a->f();
20}
21
22int main() {
23 B b;
24 foo(p: &b);
25}
26

source code of compiler-rt/test/cfi/vtable-may-alias.cpp