1// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
2// RUN: FileCheck %s < %t.out
3
4#include <stdio.h>
5
6long foo(int *x, long *y) {
7 *x = 0;
8 *y = 1;
9 // CHECK: ERROR: TypeSanitizer: type-aliasing-violation
10 // CHECK: WRITE of size 8 at {{.*}} with type long accesses an existing object of type int
11 // CHECK: {{#0 0x.* in foo .*int-long.c:}}[[@LINE-3]]
12
13 return *x;
14}
15
16int main(void) {
17 long l;
18 printf(format: "%ld\n", foo(x: (int *)&l, y: &l));
19}
20
21// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation
22

source code of compiler-rt/test/tysan/int-long.c