xref: /llvm-project/compiler-rt/test/tysan/violation-pr51837.c (revision 641fbf1524338c86c952ebb1ec8d2b497ada3cef)
1 // RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
2 // RUN: FileCheck %s < %t.out
3 
4 #include <stdint.h>
5 #include <stdio.h>
6 
7 // CHECK-NOT: TypeSanitizer
8 
9 union a {
10   int16_t b;
11   uint64_t c;
12 } d;
13 
14 uint64_t *e = &d.c;
15 static uint16_t f(int16_t a, int32_t b, uint64_t c);
16 static int64_t g(int32_t aa, uint8_t h, union a bb) {
17   int16_t *i = &d.b;
18   f(0, h, 0);
19   *i = h;
20   return 0;
21 }
22 uint16_t f(int16_t a, int32_t b, uint64_t c) {
23   for (d.c = 0; 0;)
24     ;
25   *e = 0;
26   return 0;
27 }
28 
29 int main() {
30   uint32_t j = 8;
31   g(1, j, d);
32   printf("%d\n", d.b);
33   return 0;
34 }
35