Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 1 | // RUN: %clangxx_cfi_dso -DSHARED_LIB %s -fPIC -shared -o %t-so.so |
| 2 | // RUN: %clangxx_cfi_dso %s -o %t %t-so.so && %expect_crash %t 2>&1 | FileCheck %s |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #ifdef SHARED_LIB |
| 7 | void g(); |
| 8 | void f() { |
| 9 | // CHECK: =1= |
| 10 | fprintf(stderr, "=1=\n"); |
| 11 | ((void (*)(void))g)(); |
| 12 | // CHECK: =2= |
| 13 | fprintf(stderr, "=2=\n"); |
| 14 | ((void (*)(int))g)(42); // UB here |
| 15 | // CHECK-NOT: =3= |
| 16 | fprintf(stderr, "=3=\n"); |
| 17 | } |
| 18 | #else |
| 19 | void f(); |
| 20 | void g() { |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | f(); |
| 25 | } |
| 26 | #endif |