gcc/testsuite/ChangeLog: PR sanitizer/97414 * g++.dg/asan/pr97414.C: New test.
(cherry picked from commit 6c5b08a2ca935c5db68e79d33e5c5b752252115c) --- gcc/testsuite/g++.dg/asan/pr97414.C | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 gcc/testsuite/g++.dg/asan/pr97414.C diff --git a/gcc/testsuite/g++.dg/asan/pr97414.C b/gcc/testsuite/g++.dg/asan/pr97414.C new file mode 100644 index 00000000000..6ea03906daa --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr97414.C @@ -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; +} -- 2.28.0