brintos

brintos / llvm-project-archived public Read only

0
0
Text · 678 B · 25f6633 Raw
28 lines · c
1// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&12// RUN: FileCheck %s < %t.out3 4#include <stdio.h>5 6typedef struct {7  int i1, i1b;8} s1;9typedef struct {10  int i2, i2b, i2c;11} s2;12 13void f(s1 *s1p, s2 *s2p) {14  s1p->i1 = 2;15  s2p->i2 = 3;16  // CHECK: ERROR: TypeSanitizer: type-aliasing-violation17  // CHECK: WRITE of size 4 at {{.*}} with type int (in <anonymous type> at offset 0) accesses an existing object of type int (in <anonymous type> at offset 0)18  // CHECK: {{#0 0x.* in f .*anon-struct.c:}}[[@LINE-3]]19  printf("%i\n", s1p->i1);20}21 22int main() {23  s1 s = {.i1 = 1, .i1b = 5};24  f(&s, (s2 *)&s);25}26 27// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation28