https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84340

--- Comment #10 from Paolo Bonzini <bonzini at gnu dot org> ---
> Note that we only instrument ASAN_CHECK for memory references. x=0 is not 
> that 
> case.

That depends... in use-after-scope-types-1.C there is inlining involved.  With
my pass ordering change ASAN_CHECK is added before inlining, when there is
still a *ptr.t dereference.  After inlining you get:

  ASAN_MARK (UNPOISON, &ptr, 8);
  ASAN_MARK (UNPOISON, &x, 1);
  ASAN_CHECK (7, &ptr.t, 8, 8);
  _9 = &ptr.t;
  ASAN_CHECK (7, _9, 8, 8);
  ptr.t = &x;
  ASAN_MARK (POISON, &x, 1);
  ASAN_CHECK (6, &ptr.t, 8, 8);
  ASAN_CHECK (7, &x, 1, 1);
  _10 = &x;
  ASAN_CHECK (7, _10, 1, 8);
  x = 0;
  ASAN_MARK (POISON, &ptr, 8);

But even if this weren't the case, the ASAN_MARK would be lowered to
ASAN_POISON() and everything seems to work:

    int main()
    {
        bool *ptr;
        {
            bool x;
            ptr = &x;
        }
        return *ptr;
    }

becomes

  x_8 = ASAN_POISON ();
  _6 = (int) x_8;
  return _6;

(and it is very similar to gcc.dg/asan/use-after-scope-10.c).

Reply via email to