mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-21 14:50:57 +08:00
libsanitizer: add test-case
gcc/testsuite/ChangeLog: PR sanitizer/97414 * g++.dg/asan/pr97414.C: New test.
This commit is contained in:
parent
b69f33f477
commit
6c5b08a2ca
19
gcc/testsuite/g++.dg/asan/pr97414.C
Normal file
19
gcc/testsuite/g++.dg/asan/pr97414.C
Normal file
@ -0,0 +1,19 @@
|
||||
/* PR sanitizer/97414 */
|
||||
/* { dg-do run } */
|
||||
/* { dg-set-target-env-var ASAN_OPTIONS "detect_invalid_pointer_pairs=1:halt_on_error=1,detect_stack_use_after_return=1" } */
|
||||
/* { dg-options "-fsanitize=address,pointer-compare,pointer-subtract" } */
|
||||
|
||||
[[gnu::noinline]] auto pointer_diff(const int *begin, const int *end) {
|
||||
return end - begin;
|
||||
}
|
||||
|
||||
int main() {
|
||||
constexpr auto size = (2048 / sizeof(int)) + 1;
|
||||
|
||||
auto buf = new int[size];
|
||||
auto end = buf + size;
|
||||
pointer_diff(end, buf);
|
||||
delete[] buf;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user