20 lines · c
1// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&12// RUN: FileCheck %s < %t.out3 4float *P;5void zero_array() {6 int i;7 for (i = 0; i < 1; ++i)8 P[i] = 0.0f;9 // CHECK: ERROR: TypeSanitizer: type-aliasing-violation10 // CHECK: WRITE of size 4 at {{.*}} with type float accesses an existing object of type p1 float11 // CHECK: {{#0 0x.* in zero_array .*ptr-float.c:}}[[@LINE-3]]12}13 14int main() {15 P = (float *)&P;16 zero_array();17}18 19// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation20