1 | // RUN: %clangxx_hwasan -O0 %s -o %t && %run %t |
2 | |
3 | #include <assert.h> |
4 | #include <memory> |
5 | #include <sanitizer/hwasan_interface.h> |
6 | #include <set> |
7 | #include <stdio.h> |
8 | |
9 | int main() { |
10 | auto p = std::make_unique<char>(); |
11 | std::set<void *> ptrs; |
12 | for (unsigned i = 0;; ++i) { |
13 | void *ptr = __hwasan_tag_pointer(p.get(), i); |
14 | if (!ptrs.insert(ptr).second) |
15 | break; |
16 | fprintf(stderr, "%p, %u, %u\n" , ptr, i, __hwasan_get_tag_from_pointer(ptr)); |
17 | assert(__hwasan_get_tag_from_pointer(ptr) == i); |
18 | } |
19 | #ifdef __x86_64__ |
20 | assert(ptrs.size() == 8 || ptrs.size() == 64); |
21 | #else |
22 | assert(ptrs.size() == 256); |
23 | #endif |
24 | } |
25 | |