1 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
3 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
8 int foo(char *p
, char *q
) {
12 char global1
[100] = {}, global2
[100] = {};
15 // Heap allocated memory.
16 char *heap1
= (char *)malloc(42);
17 char *heap2
= (char *)malloc(42);
19 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
20 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
24 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
25 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
26 foo(&global1
[0], &global2
[10]);
30 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
31 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
32 foo(&stack1
, &stack2
);
35 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
36 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
38 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
39 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
40 foo(heap1
, &global1
[0]);
41 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
42 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
43 foo(&stack1
, &global1
[0]);