| 1 | // RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1 |
| 2 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-SHORT %s < %t.out |
| 3 | |
| 4 | // RUN: %env_tysan_opts=print_stacktrace=1 %run %t >%t.out 2>&1 |
| 5 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-LONG %s < %t.out |
| 6 | |
| 7 | float *P; |
| 8 | void zero_array() { |
| 9 | int i; |
| 10 | for (i = 0; i < 1; ++i) |
| 11 | P[i] = 0.0f; |
| 12 | // CHECK: ERROR: TypeSanitizer: type-aliasing-violation |
| 13 | // CHECK: WRITE of size 4 at {{.*}} with type float accesses an existing object of type p1 float |
| 14 | // CHECK: {{#0 0x.* in zero_array .*print_stacktrace.c:}}[[@LINE-3]] |
| 15 | // CHECK-SHORT-NOT: {{#1 0x.* in main .*print_stacktrace.c}} |
| 16 | // CHECK-LONG-NEXT: {{#1 0x.* in main .*print_stacktrace.c}} |
| 17 | } |
| 18 | |
| 19 | int main() { |
| 20 | P = (float *)&P; |
| 21 | zero_array(); |
| 22 | } |
| 23 | |