1extern void abort (void);
2
3typedef unsigned long my_uintptr_t;
4
5int check_a(my_uintptr_t tagged_ptr);
6
7int __attribute__((noinline)) try_a(my_uintptr_t x)
8{
9  my_uintptr_t heap[2];
10  my_uintptr_t *hp = heap;
11
12  hp[0] = x;
13  hp[1] = 0;
14  return check_a((my_uintptr_t)(void*)((char*)hp + 1));
15}
16
17int __attribute__((noinline)) check_a(my_uintptr_t tagged_ptr)
18{
19  my_uintptr_t *hp = (my_uintptr_t*)(void*)((char*)tagged_ptr - 1);
20
21  if (hp[0] == 42 && hp[1] == 0)
22    return 0;
23  return -1;
24}
25
26int main(void)
27{
28  if (try_a(42) < 0)
29    abort ();
30  return 0;
31}
32
33