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 <jakub@redhat.com>
* 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.
/* { 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)
{
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;
}