reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
// RUN: %clangxx_cfi -o %t %s
// RUN: %run %t

// In this example, both __typeid_A_global_addr and __typeid_B_global_addr will
// refer to the same address. Make sure that the compiler does not assume that
// they do not alias.

struct A {
  virtual void f() = 0;
};

struct B : A {
  virtual void f() {}
};

__attribute__((weak)) void foo(void *p) {
  B *b = (B *)p;
  A *a = (A *)b;
  a->f();
}

int main() {
  B b;
  foo(&b);
}