[llvm-branch-commits] [compiler-rt] [TySan] Fix struct access with different bases (PR #108385)
Jeremy Morse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 11 10:08:48 PST 2024
================
@@ -0,0 +1,31 @@
+// RUN: %clangxx_tysan -O0 %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+#include <stdio.h>
+
+struct inner {
+ char buffer;
+ int i;
+};
+
+void init_inner(inner *iPtr) {
+ iPtr->i = 0;
+}
+
+struct outer {
+ inner foo;
+ char buffer;
+};
+
+int main(void) {
+ outer *l = new outer();
+
+ init_inner(&l->foo);
+
+ int access_offsets_with_different_base = l->foo.i;
+ printf("%d\n", access_offsets_with_different_base);
+
+ return 0;
+}
+
+// CHECK-NOT: ERROR: TypeSanitizer: type-aliasing-violation
----------------
jmorse wrote:
Nit: please also include a test for /something/ in the output to ensure that the test is positively checking for something. Otherwise we could replace %clangxx_tysan with any program that succeeds , such as `true`, and this test would pass.
https://github.com/llvm/llvm-project/pull/108385
More information about the llvm-branch-commits
mailing list