<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113533>113533</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Add `lifetimebound` to ArrayRef and StringRef to detect dangling issues
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:memory-safety
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hokein
</td>
</tr>
</table>
<pre>
Adding the lifetimebound annotation to the `ArrayRef`'s array constructor can enable us to detect the following use-after-free issues:
```
ArrayRef<int> test() {
int array[10];
return array; // bug, return a stack local address
}
```
cc @Xazax-hun, @usx95
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsks9unDAQxp9muFi7MjZ_woHDbrb7AO2l18EM4MZrR_Y4zfbpK1iSqFIlNGj0wTdjfz9Myc6eqIf6DPWlwMxLiP0SXsj6YgjjvT-No_Wz4IWEsxOxvdEQsh8Feh8Y2QYvOGw6NPIUI96_0wSNBNUmgWsvTPCJYzYcojDoBXkcHImc1j9HYjK8GUzBufB7HZcTHXBiiocpEgmbUqYE-gTyAvKjNnJ_tvZztH62nkF_E0yJQT2B6gS058dXQgjr-bEX1OdSQn0B_SVG4hz9ruuzAHUFdRVDnkE9f6oiMZoX4YJBJ3AcI6W0L9Ve_rvdoxojoJI_8Q--H5bsV0uoZE7vXS2KsddjpzssqC9b1bV13emmWPrxqTOTRENyattGdZpqJVWDDXVTOzWysL2SqiqlqmRb1bo51o1EpZvaKFM-la2BStINrTs693Y7hjgX24X2ZalrrQuHA7m0MaCUcehn0Kcb3UK8HxJOxHdQasUj9qvBYchzgko6mzh9WbJlRysuKwf_oAKNXIP-CEigH8UPjtbPa_eFwIh-dmv6j7iLHF2_ML9uwW85zJaXPBxNuIG6rpP31-E1hl9kGNR1R0Vd98O99epvAAAA__-e2eff">