27 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 6// The two anonymous structs are structurally identical. As a result, we don't7// report an aliasing violation here.8// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation9 10typedef struct {11 int i1;12} s1;13typedef struct {14 int i2;15} s2;16 17void f(s1 *s1p, s2 *s2p) {18 s1p->i1 = 2;19 s2p->i2 = 3;20 printf("%i\n", s1p->i1);21}22 23int main() {24 s1 s = {.i1 = 1};25 f(&s, (s2 *)&s);26}27