<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61787>61787</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
             Regression bug in ASAN: since Clang-7, it cannot report certain use-after-scope bugs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          shao-hua-li
      </td>
    </tr>
</table>

<pre>
    For the following code, ASAN at -O0 failed to report the use-after-scope since Clang-7.
GCC's ASAN can detect it normally.

Compiler explorer: https://godbolt.org/z/1PEaocv9o

```shell
% cat a.c
struct a {
  signed b;
} d;
int *c;
struct a e() {
  {
    struct a f;
    c = &f.b;
    for (; 0;)
      return f;
  }
  *c = 0;
  return d;
}
int main() { e(); }
%
% clang-tk -O0 -fsanitize=address a.c && ./a.out

% clang-6 -O0 -fsanitize=address a.c && ./a.out
=================================================================
==1==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffec29573b0 at pc 0x000000511cf8 bp 0x7ffec2957370 sp 0x7ffec2957368
WRITE of size 4 at 0x7ffec29573b0 thread T0
    #0 0x511cf7 in e /a.c:12:6
    #1 0x511e85 in main /a.c:15:14
    #2 0x7f4c02729082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)
    #3 0x41971d in _start (/app/output.s+0x41971d)
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVU2PozgT_jXOpQQyZT4PHOhO8-q97KwyI-0xMsYk3nEwsk1Ppn_9ypDv4942QuBUPfXYVa4P7pw6jFLWJHsj2XbDZ380tnZHbqLjzCOtNp3pf9etseCPEgajtfmlxgMI00uC79B8b_4A7iH6RmHgSssevAErJ2P9YjI7GfHBSxs5YSYJTo1Cwrvm4yEqYkK3hDb_e38nWLiVTPAReuml8KA8jMaeuNa_L8j1_W5Ok9LSgjxP2lhpCWvg6P3kCGsItgTbg-k7o31s7IFg-0WwTf784EZ8VuaRieR0fdxRan2RYQaCe-CxWAXO21l44ECKt1UCsMSth46wi4gUW-hv_9TogWAjboIbhyRYEqweuR6WADfgcLMNYgGEbYFgPsTdk2IwFgIlewMaFFjddQBW-tmOT1yk2N6W2Ky89EF_MekfPbs7deJqvHtw9SbsfoMRzB4CuVy0_7kkSDQ4PiqvviRhW973VjoXwhz8IphDTLDlsZn93f6VKf9XRGz7n38eHEnWz8du920XMr9ZA_D9EpKlGpzn4mf0WnxmhGu06LkYBimwygrW0VDCkwB6pssvSxIxlNBNT7CCgnuW5OV6rr92___xAWYAp74kpIHthd8freQ9_KD37CTIKNDzslcBagQJy7UJwpoECWvyJ2yyYmWZBWzIwwd4Fl7pEx6XI6SCYoEVLTFY7fdadWLvPLd-f6EoCbZadQTbc5nv8zTSapzP0WGcV4WInYlzgm_0jCkt8anCCDIG9JwmVZH0yw4L94WWTxPB1sx-mn3sFooVeeO418q1EW36mvUVq_hG1kleUlqUZZZvjrXshRBJVXI2VIlgg-AoUyy7smIs42zYqBopMsqCtyxN8liILENJh0okSLshISmVJ650rPXnKXTGjXJulnWeFGWx0byT2i2TAHGUv2BREsQwGGwdbKJuPjiSUq2cd3cWr7yWNezkIWSWMiN08yEEI_TzJRkfe36YGsqHNj8af50UQlofruM1YcOGm9nq-qW7K3-cu1iYU7gj_Xn9RJM1f0vhCbbL6R3BdvHunwAAAP__xO_nug">