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
6// The two anonymous structs are structurally identical. As a result, we don't
7// report an aliasing violation here.
8// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation
9
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(format: "%i\n", s1p->i1);
21}
22
23int main() {
24 s1 s = {.i1 = 1};
25 f(s1p: &s, s2p: (s2 *)&s);
26}
27

source code of compiler-rt/test/tysan/anon-same-struct.c