https://gcc.gnu.org/g:77705b475df4e4eed5831bf27e37250db2135fc8
commit r16-5303-g77705b475df4e4eed5831bf27e37250db2135fc8 Author: Jakub Jelinek <[email protected]> Date: Sat Nov 15 16:06:05 2025 +0100 testsuite: Fix up c-c++-common/asan/asan-stack-small.c test Here is a fix for the test I've talked about today in the libsanitizer update mail. The test relied on a coming before b coming before c, all with 32 byte distances, but gcc can actually emit them in the exact opposite order or some other one. 2025-11-15 Jakub Jelinek <[email protected]> * c-c++-common/asan/asan-stack-small.c (pa, pb, pc): Make these vars volatile. (uintptr_t): New typedef. (main): Use access of b using pa pointer with offset depending on how exactly the 3 variables are laid out in the frame. Diff: --- gcc/testsuite/c-c++-common/asan/asan-stack-small.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/c-c++-common/asan/asan-stack-small.c b/gcc/testsuite/c-c++-common/asan/asan-stack-small.c index 11a56b8db4cb..d045406c9fb1 100644 --- a/gcc/testsuite/c-c++-common/asan/asan-stack-small.c +++ b/gcc/testsuite/c-c++-common/asan/asan-stack-small.c @@ -1,8 +1,9 @@ /* { dg-do run } */ -char *pa; -char *pb; -char *pc; +char *volatile pa; +char *volatile pb; +char *volatile pc; +typedef __UINTPTR_TYPE__ uintptr_t; void access (volatile char *ptr) { @@ -22,7 +23,14 @@ int main (int argc, char **argv) access (pb); access (pc); // access 'b' here - access (pa + 32); + if ((uintptr_t) pb == (uintptr_t) pa + 32) + access (pa + 32); + else if ((uintptr_t) pb == (uintptr_t) pa - 32) + access (pa - 32); + else if ((uintptr_t) pb == (uintptr_t) pa + 64) + access (pa + 64); + else if ((uintptr_t) pb == (uintptr_t) pa - 64) + access (pa - 64); return 0; }
