Debian Codegraph @

gcc/testsuite/g++.dg/asan/pr97414.C

raw
1 /* PR sanitizer/97414 */
2 /* { dg-do run } */
3 /* { dg-set-target-env-var ASAN_OPTIONS "detect_invalid_pointer_pairs=1:halt_on_error=1,detect_stack_use_after_return=1" } */
4 /* { dg-options "-fsanitize=address,pointer-compare,pointer-subtract" } */
5
6 [[gnu::noinline]] auto pointer_diff(const int *begin, const int *end) {
7 return end - begin;
8 }
9
10 int main() {
11 constexpr auto size = (2048 / sizeof(int)) + 1;
12
13 auto buf = new int[size];
14 auto end = buf + size;
15 pointer_diff(end, buf);
16 delete[] buf;
17
18 return 0;
19 }