1 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
3 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2 %run %t
13 int bar(char *p
, char *q
) {
17 int baz(char *p
, char *q
) {
18 return p
!= 0 && p
< q
;
21 char global
[8192] = {};
22 char small_global
[7] = {};
25 // Heap allocated memory.
26 char *p
= (char *)malloc(42);
30 p
= (char *)malloc(1024);
32 bar(p
+ 1024, p
+ 1023);
36 p
= (char *)malloc(4096);
39 bar(p
+ 1024, p
+ 4096);
40 bar(p
+ 4095, p
+ 4096);
41 bar(p
+ 4095, p
+ 4094);
42 bar(p
+ 100, p
+ 4096);
43 bar(p
+ 100, p
+ 4094);
47 bar(&global
[0], &global
[1]);
48 bar(&global
[1], &global
[2]);
49 bar(&global
[2], &global
[1]);
50 bar(&global
[0], &global
[100]);
51 bar(&global
[1000], &global
[7000]);
52 bar(&global
[500], &global
[10]);
67 bar(&stack
[0], &stack
[100]);
68 bar(&stack
[1000], &stack
[9000]);
69 bar(&stack
[500], &stack
[10]);