llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/120038.diff 1 Files Affected: - (added) compiler-rt/test/ubsan/TestCases/Misc/local_bounds.cpp (+28) ``````````diff diff --git a/compiler-rt/test/ubsan/TestCases/Misc/local_bounds.cpp b/compiler-rt/test/ubsan/TestCases/Misc/local_bounds.cpp new file mode 100644 index 00000000000000..92e9e62dbc8698 --- /dev/null +++ b/compiler-rt/test/ubsan/TestCases/Misc/local_bounds.cpp @@ -0,0 +1,28 @@ +// RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && %run %t 1 +// RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && not --crash %run %t 3 + +// FIXME: it's always trap for now. + +#include <cstdlib> + +struct S { + int k; + int l; +}; + +__attribute__((noinline)) void init(S *s) { + __asm__ __volatile__("" : : "r"(s) : "memory"); +} + +__attribute__((noinline, no_sanitize("memory"))) int test(char i) { + S a; + init(&a); + S b; + init(&b); + return ((int*)(&a))[i]; +} + +int main(int argc, char **argv) { + test(argv[1][0] - '0'); + return 0; +} `````````` </details> https://github.com/llvm/llvm-project/pull/120038 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits