1  /* { dg-do run } */
       2  
       3  /* This is a simplified version of what Emacs does internally,
       4     when marking its stack.  */
       5  
       6  static unsigned long sum;
       7  static void *stack_base;
       8  
       9  /* A simple substitute for what Emacs actually does.  */
      10  static void
      11  mark_maybe_pointer (void *p)
      12  {
      13    sum ^= (unsigned long) p;
      14  }
      15  
      16  static inline void __attribute__ ((no_sanitize_address))
      17  mark_memory (void **start, void **end)
      18  {
      19    void **pp;
      20  
      21    if (end < start)
      22      {
      23        void **tem = start;
      24        start = end;
      25        end = tem;
      26      }
      27  
      28    for (pp = start; pp < end; pp++)
      29      {
      30        /* This is the dereference that we don't want sanitized.  */
      31        void *p = *pp;
      32  
      33        mark_maybe_pointer (p);
      34      }
      35  }
      36  
      37  static void
      38  mark_stack (void)
      39  {
      40    void *end;
      41    mark_memory (stack_base, &end);
      42  }
      43  
      44  void
      45  garbage_collect (void)
      46  {
      47    mark_stack ();
      48  }
      49  
      50  int
      51  main (void)
      52  {
      53    void *dummy;
      54    stack_base = &dummy;
      55    garbage_collect ();
      56    return 0;
      57  }