[clang] [compiler-rt] [llvm] [TySan] A Type Sanitizer (Runtime Library) (PR #76261)

Shafik Yaghmour via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 18:54:20 PST 2024


================
@@ -0,0 +1,18 @@
+// RUN: %clang_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+#include <stdio.h>
+
+// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation
+
+int main() {
+  union {
+    int i;
+    short s;
+  } u;
+
+  u.i = 42;
+  u.s = 1;
+
+  printf("%d\n", u.i);
----------------
shafik wrote:

In C++ this would be a aliasing violation, can we catch that in C++?

https://github.com/llvm/llvm-project/pull/76261


More information about the llvm-commits mailing list