From: Jakub Jelinek Date: Sat, 15 Nov 2025 15:06:05 +0000 (+0100) Subject: testsuite: Fix up c-c++-common/asan/asan-stack-small.c test X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77705b475df4e4eed5831bf27e37250db2135fc8;p=thirdparty%2Fgcc.git 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 * 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 --git a/gcc/testsuite/c-c++-common/asan/asan-stack-small.c b/gcc/testsuite/c-c++-common/asan/asan-stack-small.c index 11a56b8db4c..d045406c9fb 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; }