[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / invalid-pointer-pairs-compare-null.cpp
blob9f7f7b6f439d5b8bfaacab3a6c96a1c23bde0db2
1 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
3 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=1 %run %t
5 #include <assert.h>
6 #include <stdlib.h>
8 int foo(char *p, char *q) {
9 return p <= q;
12 char global[8192] = {};
13 char small_global[7] = {};
15 int main() {
16 // Heap allocated memory.
17 char *p = (char *)malloc(42);
18 int r = foo(p, NULL);
19 free(p);
21 p = (char *)malloc(1024);
22 foo(NULL, p);
23 free(p);
25 p = (char *)malloc(4096);
26 foo(p, NULL);
27 free(p);
29 // Global variable.
30 foo(&global[0], NULL);
31 foo(&global[1000], NULL);
33 p = &small_global[0];
34 foo(p, NULL);
36 // Stack variable.
37 char stack[10000];
38 foo(&stack[0], NULL);
39 foo(NULL, &stack[9000]);
41 return 0;