23 lines · c
1// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&12// RUN: FileCheck --check-prefixes=CHECK,CHECK-SHORT %s < %t.out3 4// RUN: %env_tysan_opts=print_stacktrace=1 %run %t >%t.out 2>&15// RUN: FileCheck --check-prefixes=CHECK,CHECK-LONG %s < %t.out6 7float *P;8void zero_array() {9 int i;10 for (i = 0; i < 1; ++i)11 P[i] = 0.0f;12 // CHECK: ERROR: TypeSanitizer: type-aliasing-violation13 // CHECK: WRITE of size 4 at {{.*}} with type float accesses an existing object of type p1 float14 // 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 19int main() {20 P = (float *)&P;21 zero_array();22}23