1 // RUN: %clangxx_asan -O2 -fsanitize-address-outline-instrumentation %s -o %t
2 // RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
3 // RUN: not %run %t B 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
4 // RUN: not %run %t C 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
5 // RUN: not %run %t D 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
7 // RUN: %clangxx_asan -O2 -fsanitize-address-outline-instrumentation %s -o %t \
8 // RUN: -mllvm -asan-recover=1
9 // RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
10 // RUN: not %run %t B 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
11 // RUN: not %run %t C 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
12 // RUN: not %run %t D 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
14 // RUN: %clangxx_asan -O2 -fsanitize-address-outline-instrumentation %s -o %t \
15 // RUN: -mllvm -asan-force-experiment=42
16 // RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
17 // RUN: not %run %t B 2>&1 | FileCheck %s --check-prefix=CHECK_0_BYTES
18 // RUN: not %run %t C 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
19 // RUN: not %run %t D 2>&1 | FileCheck %s --check-prefix=CHECK_1_BYTES
21 // CHECK_0_BYTES: ERROR: AddressSanitizer: global-buffer-overflow on address [[ADDR:.*]] at
22 // CHECK_0_BYTES: [[ADDR]] is located 0 bytes after
24 // CHECK_1_BYTES: ERROR: AddressSanitizer: global-buffer-overflow on address [[ADDR:.*]] at
25 // CHECK_1_BYTES: [[ADDR]] is located 1 bytes after
27 #include <sanitizer/asan_interface.h>
32 static int64_t mem
= -1;
33 static int64_t *volatile G
= &mem
;
35 inline uint16_t UNALIGNED_LOAD(const void *p
) {
37 memcpy(&data
, p
, sizeof data
);
41 inline void UNALIGNED_STORE(uint16_t data
, void *p
) {
42 memcpy(p
, &data
, sizeof data
);
45 int main(int argc
, char **argv
) {
51 res
= UNALIGNED_LOAD(reinterpret_cast<char *>(G
) + 7);
54 UNALIGNED_STORE(0, reinterpret_cast<char *>(G
) + 7);
57 res
= UNALIGNED_LOAD(reinterpret_cast<char *>(G
) + 9);
60 UNALIGNED_STORE(0, reinterpret_cast<char *>(G
) + 9);