1 // RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && %run %t 1
2 // RUN: %clangxx -fsanitize=local-bounds %s -O3 -o %t && not --crash %run %t 3
3 // RUN: %clangxx -fsanitize=local-bounds -fno-sanitize-trap=local-bounds %s -O3 -o %t && not --crash %run %t 3 2>&1 | FileCheck %s
4 // RUN: %clangxx -fsanitize=local-bounds -fno-sanitize-trap=local-bounds -fsanitize-recover=local-bounds %s -O3 -o %t && %run %t 3 2>&1 | FileCheck %s
13 __attribute__((noinline
)) void init(S
*s
) {
14 __asm__
__volatile__("" : : "r"(s
) : "memory");
17 __attribute__((noinline
, no_sanitize("memory"))) int test(char i
) {
22 return ((int *)(&a
))[i
];
23 // CHECK: ubsan: local-out-of-bounds by 0x{{[[:xdigit:]]+$}}
26 int main(int argc
, char **argv
) {
27 test(argv
[1][0] - '0');